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

Side by Side Diff: test/BaseJsTest.h

Issue 29500602: Issue 5450 - introduce the Platform class (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Patch Set: Created July 28, 2017, 12:40 p.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 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 #ifndef MOCKS_H 18 #ifndef MOCKS_H
19 #define MOCKS_H 19 #define MOCKS_H
20 20
21 #include <thread> 21 #include <thread>
22 22
23 #include <AdblockPlus.h> 23 #include <AdblockPlus.h>
24 #include <AdblockPlus/Platform.h>
24 #include <gtest/gtest.h> 25 #include <gtest/gtest.h>
25 #include "../src/Thread.h" 26 #include "../src/Thread.h"
26 27
27 // Strictly speaking in each test there should be a special implementation of 28 // Strictly speaking in each test there should be a special implementation of
28 // an interface, which is merely referenced by a wrapper and the latter should 29 // an interface, which is merely referenced by a wrapper and the latter should
29 // be injected into JsEngine or what ever. However the everthing a test often 30 // be injected into JsEngine or what ever. However the everthing a test often
30 // actually needs is the access to pending tasks. Therefore instantiation of 31 // actually needs is the access to pending tasks. Therefore instantiation of
31 // implemenation of an interface, creation of shared tasks and sharing them 32 // implemenation of an interface, creation of shared tasks and sharing them
32 // with tasks in test is located in this class. 33 // with tasks in test is located in this class.
33 // 34 //
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 250
250 class LazyLogSystem : public AdblockPlus::LogSystem 251 class LazyLogSystem : public AdblockPlus::LogSystem
251 { 252 {
252 public: 253 public:
253 void operator()(LogLevel logLevel, const std::string& message, 254 void operator()(LogLevel logLevel, const std::string& message,
254 const std::string& source) 255 const std::string& source)
255 { 256 {
256 } 257 }
257 }; 258 };
258 259
259 struct JsEngineCreationParameters 260 struct ThrowingPlatformCreationParameters: AdblockPlus::Platform::CreationParame ters
260 { 261 {
261 JsEngineCreationParameters(); 262 ThrowingPlatformCreationParameters();
262
263 AdblockPlus::AppInfo appInfo;
264 AdblockPlus::LogSystemPtr logSystem;
265 AdblockPlus::TimerPtr timer;
266 AdblockPlus::WebRequestPtr webRequest;
267 AdblockPlus::FileSystemPtr fileSystem;
268 }; 263 };
269 264
270 AdblockPlus::JsEnginePtr CreateJsEngine(JsEngineCreationParameters&& jsEngineCre ationParameters = JsEngineCreationParameters());
271
272 class BaseJsTest : public ::testing::Test 265 class BaseJsTest : public ::testing::Test
273 { 266 {
274 protected: 267 protected:
275 AdblockPlus::JsEnginePtr jsEngine; 268 std::unique_ptr<AdblockPlus::Platform> platform;
276 269
277 virtual void SetUp() 270 virtual void SetUp()
278 { 271 {
279 jsEngine = CreateJsEngine(); 272 platform.reset(new AdblockPlus::Platform(ThrowingPlatformCreationParameters( )));
280 } 273 }
281 }; 274 };
282 275
283 #endif 276 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld