Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: test/BaseJsTest.h

Issue 10369004: File system path resolving (Closed)
Patch Set: Comments addressed Created April 30, 2013, 8:09 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 #ifndef MOCKS_H 1 #ifndef MOCKS_H
2 #define MOCKS_H 2 #define MOCKS_H
3 3
4 #include <AdblockPlus.h> 4 #include <AdblockPlus.h>
5 #include <gtest/gtest.h> 5 #include <gtest/gtest.h>
6 #include "../src/Thread.h" 6 #include "../src/Thread.h"
7 7
8 class ThrowingErrorCallback : public AdblockPlus::ErrorCallback 8 class ThrowingErrorCallback : public AdblockPlus::ErrorCallback
9 { 9 {
10 public: 10 public:
(...skipping 23 matching lines...) Expand all
34 34
35 void Remove(const std::string& path) 35 void Remove(const std::string& path)
36 { 36 {
37 throw std::runtime_error("Not implemented"); 37 throw std::runtime_error("Not implemented");
38 } 38 }
39 39
40 StatResult Stat(const std::string& path) const 40 StatResult Stat(const std::string& path) const
41 { 41 {
42 throw std::runtime_error("Not implemented"); 42 throw std::runtime_error("Not implemented");
43 } 43 }
44
45 std::string Resolve(const std::string& path) const
46 {
47 throw std::runtime_error("Not implemented");
48 }
49
50 void SetBasePath(const std::string& path)
51 {
52 throw std::runtime_error("Not implemented");
53 }
54
44 }; 55 };
45 56
46 class ThrowingWebRequest : public AdblockPlus::WebRequest 57 class ThrowingWebRequest : public AdblockPlus::WebRequest
47 { 58 {
48 AdblockPlus::ServerResponse GET(const std::string& url, const AdblockPlus::Hea derList& requestHeaders) const 59 AdblockPlus::ServerResponse GET(const std::string& url, const AdblockPlus::Hea derList& requestHeaders) const
49 { 60 {
50 throw std::runtime_error("Unexpected GET: " + url); 61 throw std::runtime_error("Unexpected GET: " + url);
51 } 62 }
52 }; 63 };
53 64
(...skipping 24 matching lines...) Expand all
78 while (true) 89 while (true)
79 AdblockPlus::Sleep(100000); 90 AdblockPlus::Sleep(100000);
80 } 91 }
81 92
82 StatResult Stat(const std::string& path) const 93 StatResult Stat(const std::string& path) const
83 { 94 {
84 while (true) 95 while (true)
85 AdblockPlus::Sleep(100000); 96 AdblockPlus::Sleep(100000);
86 return StatResult(); 97 return StatResult();
87 } 98 }
99
100 std::string Resolve(const std::string& path) const
101 {
102 while (true)
103 AdblockPlus::Sleep(100000);
104 return std::string();
105 }
106
107 void SetBasePath(const std::string& path)
108 {
109 while (true)
110 AdblockPlus::Sleep(100000);
Wladimir Palant 2013/04/30 09:29:50 SetBasePath() isn't a function called from JS, no
111 }
88 }; 112 };
89 113
90 class LazyWebRequest : public AdblockPlus::WebRequest 114 class LazyWebRequest : public AdblockPlus::WebRequest
91 { 115 {
92 AdblockPlus::ServerResponse GET(const std::string& url, const AdblockPlus::Hea derList& requestHeaders) const 116 AdblockPlus::ServerResponse GET(const std::string& url, const AdblockPlus::Hea derList& requestHeaders) const
93 { 117 {
94 while (true) 118 while (true)
95 AdblockPlus::Sleep(100000); 119 AdblockPlus::Sleep(100000);
96 return AdblockPlus::ServerResponse(); 120 return AdblockPlus::ServerResponse();
97 } 121 }
98 }; 122 };
99 123
100 124
101 class BaseJsTest : public ::testing::Test 125 class BaseJsTest : public ::testing::Test
102 { 126 {
103 protected: 127 protected:
104 AdblockPlus::JsEnginePtr jsEngine; 128 AdblockPlus::JsEnginePtr jsEngine;
105 129
106 virtual void SetUp() 130 virtual void SetUp()
107 { 131 {
108 jsEngine = AdblockPlus::JsEngine::New(); 132 jsEngine = AdblockPlus::JsEngine::New();
109 jsEngine->SetErrorCallback(AdblockPlus::ErrorCallbackPtr(new ThrowingErrorCa llback)); 133 jsEngine->SetErrorCallback(AdblockPlus::ErrorCallbackPtr(new ThrowingErrorCa llback));
110 jsEngine->SetFileSystem(AdblockPlus::FileSystemPtr(new ThrowingFileSystem)); 134 jsEngine->SetFileSystem(AdblockPlus::FileSystemPtr(new ThrowingFileSystem));
111 jsEngine->SetWebRequest(AdblockPlus::WebRequestPtr(new ThrowingWebRequest)); 135 jsEngine->SetWebRequest(AdblockPlus::WebRequestPtr(new ThrowingWebRequest));
112 } 136 }
113 }; 137 };
114 138
115 #endif 139 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld