OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2013 Eyeo GmbH | 3 * Copyright (C) 2006-2013 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 AdblockPlus::ServerResponse GET(const std::string& url, const AdblockPlus::Hea
derList& requestHeaders) const | 72 AdblockPlus::ServerResponse GET(const std::string& url, const AdblockPlus::Hea
derList& requestHeaders) const |
73 { | 73 { |
74 throw std::runtime_error("Unexpected GET: " + url); | 74 throw std::runtime_error("Unexpected GET: " + url); |
75 } | 75 } |
76 }; | 76 }; |
77 | 77 |
78 class LazyFileSystem : public AdblockPlus::FileSystem | 78 class LazyFileSystem : public AdblockPlus::FileSystem |
79 { | 79 { |
80 std::tr1::shared_ptr<std::istream> Read(const std::string& path) const | 80 std::tr1::shared_ptr<std::istream> Read(const std::string& path) const |
81 { | 81 { |
82 while (true) | 82 if (path == "patterns.ini") |
83 AdblockPlus::Sleep(100000); | 83 { |
84 return std::tr1::shared_ptr<std::istream>(); | 84 std::string dummyData("# Adblock Plus preferences\n[Subscription]\nurl=~fl
~"); |
| 85 return std::tr1::shared_ptr<std::istream>(new std::istringstream(dummyData
)); |
| 86 } |
| 87 else |
| 88 return std::tr1::shared_ptr<std::istream>(); |
85 } | 89 } |
86 | 90 |
87 void Write(const std::string& path, | 91 void Write(const std::string& path, |
88 std::tr1::shared_ptr<std::ostream> content) | 92 std::tr1::shared_ptr<std::ostream> content) |
89 { | 93 { |
90 while (true) | |
91 AdblockPlus::Sleep(100000); | |
92 } | 94 } |
93 | 95 |
94 void Move(const std::string& fromPath, const std::string& toPath) | 96 void Move(const std::string& fromPath, const std::string& toPath) |
95 { | 97 { |
96 while (true) | |
97 AdblockPlus::Sleep(100000); | |
98 } | 98 } |
99 | 99 |
100 void Remove(const std::string& path) | 100 void Remove(const std::string& path) |
101 { | 101 { |
102 while (true) | |
103 AdblockPlus::Sleep(100000); | |
104 } | 102 } |
105 | 103 |
106 StatResult Stat(const std::string& path) const | 104 StatResult Stat(const std::string& path) const |
107 { | 105 { |
108 while (true) | 106 StatResult result; |
109 AdblockPlus::Sleep(100000); | 107 if (path == "patterns.ini") |
110 return StatResult(); | 108 { |
| 109 result.exists = true; |
| 110 result.isFile = true; |
| 111 } |
| 112 return result; |
111 } | 113 } |
112 | 114 |
113 std::string Resolve(const std::string& path) const | 115 std::string Resolve(const std::string& path) const |
114 { | 116 { |
115 return std::string(); | 117 return path; |
116 } | 118 } |
117 }; | 119 }; |
118 | 120 |
119 class LazyWebRequest : public AdblockPlus::WebRequest | 121 class LazyWebRequest : public AdblockPlus::WebRequest |
120 { | 122 { |
121 AdblockPlus::ServerResponse GET(const std::string& url, const AdblockPlus::Hea
derList& requestHeaders) const | 123 AdblockPlus::ServerResponse GET(const std::string& url, const AdblockPlus::Hea
derList& requestHeaders) const |
122 { | 124 { |
123 while (true) | 125 while (true) |
124 AdblockPlus::Sleep(100000); | 126 AdblockPlus::Sleep(100000); |
125 return AdblockPlus::ServerResponse(); | 127 return AdblockPlus::ServerResponse(); |
126 } | 128 } |
127 }; | 129 }; |
128 | 130 |
129 | 131 |
130 class BaseJsTest : public ::testing::Test | 132 class BaseJsTest : public ::testing::Test |
131 { | 133 { |
132 protected: | 134 protected: |
133 AdblockPlus::JsEnginePtr jsEngine; | 135 AdblockPlus::JsEnginePtr jsEngine; |
134 | 136 |
135 virtual void SetUp() | 137 virtual void SetUp() |
136 { | 138 { |
137 jsEngine = AdblockPlus::JsEngine::New(); | 139 jsEngine = AdblockPlus::JsEngine::New(); |
138 jsEngine->SetLogSystem(AdblockPlus::LogSystemPtr(new ThrowingLogSystem)); | 140 jsEngine->SetLogSystem(AdblockPlus::LogSystemPtr(new ThrowingLogSystem)); |
139 jsEngine->SetFileSystem(AdblockPlus::FileSystemPtr(new ThrowingFileSystem)); | 141 jsEngine->SetFileSystem(AdblockPlus::FileSystemPtr(new ThrowingFileSystem)); |
140 jsEngine->SetWebRequest(AdblockPlus::WebRequestPtr(new ThrowingWebRequest)); | 142 jsEngine->SetWebRequest(AdblockPlus::WebRequestPtr(new ThrowingWebRequest)); |
141 } | 143 } |
142 }; | 144 }; |
143 | 145 |
144 #endif | 146 #endif |
OLD | NEW |