OLD | NEW |
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 |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 using namespace AdblockPlus; | 24 using namespace AdblockPlus; |
25 | 25 |
26 namespace | 26 namespace |
27 { | 27 { |
28 class BaseWebRequestTest : public ::testing::Test | 28 class BaseWebRequestTest : public ::testing::Test |
29 { | 29 { |
30 protected: | 30 protected: |
31 void SetUp() | 31 void SetUp() |
32 { | 32 { |
33 JsEngineCreationParameters jsEngineParams; | 33 ThrowingPlatformCreationParameters platformParams; |
34 jsEngineParams.logSystem = CreateLogSystem(); | 34 platformParams.logSystem = CreateLogSystem(); |
35 jsEngineParams.timer.reset(new NoopTimer()); | 35 platformParams.timer.reset(new NoopTimer()); |
36 jsEngineParams.fileSystem.reset(fileSystem = new LazyFileSystem()); | 36 platformParams.fileSystem.reset(fileSystem = new LazyFileSystem()); |
37 jsEngineParams.webRequest = CreateWebRequest(); | 37 platformParams.webRequest = CreateWebRequest(); |
38 jsEngine = CreateJsEngine(std::move(jsEngineParams)); | 38 platform.reset(new Platform(std::move(platformParams))); |
| 39 jsEngine = platform->GetJsEngine(); |
39 } | 40 } |
40 | 41 |
41 virtual WebRequestPtr CreateWebRequest() = 0; | 42 virtual WebRequestPtr CreateWebRequest() = 0; |
42 | 43 |
43 virtual LogSystemPtr CreateLogSystem() | 44 virtual LogSystemPtr CreateLogSystem() |
44 { | 45 { |
45 return LogSystemPtr(new ThrowingLogSystem()); | 46 return LogSystemPtr(new ThrowingLogSystem()); |
46 } | 47 } |
47 | 48 |
| 49 std::unique_ptr<Platform> platform; |
48 JsEnginePtr jsEngine; | 50 JsEnginePtr jsEngine; |
49 LazyFileSystem* fileSystem; | 51 LazyFileSystem* fileSystem; |
50 }; | 52 }; |
51 | 53 |
52 class DefaultWebRequestTest : public BaseWebRequestTest | 54 class DefaultWebRequestTest : public BaseWebRequestTest |
53 { | 55 { |
54 WebRequestPtr CreateWebRequest() override | 56 WebRequestPtr CreateWebRequest() override |
55 { | 57 { |
56 return CreateDefaultWebRequest([this](const SchedulerTask& task) | 58 return CreateDefaultWebRequest([this](const SchedulerTask& task) |
57 { | 59 { |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 EXPECT_EQ(AdblockPlus::LogSystem::LOG_LEVEL_TRACE, catchLogSystem->lastLogLeve
l); | 367 EXPECT_EQ(AdblockPlus::LogSystem::LOG_LEVEL_TRACE, catchLogSystem->lastLogLeve
l); |
366 EXPECT_EQ("", catchLogSystem->lastMessage); | 368 EXPECT_EQ("", catchLogSystem->lastMessage); |
367 ProcessPendingWebRequests(); | 369 ProcessPendingWebRequests(); |
368 { | 370 { |
369 auto headersRequest = GetHeadersForRequest(url); | 371 auto headersRequest = GetHeadersForRequest(url); |
370 EXPECT_TRUE(headersRequest.first); | 372 EXPECT_TRUE(headersRequest.first); |
371 const auto& headers = headersRequest.second; | 373 const auto& headers = headersRequest.second; |
372 EXPECT_FALSE(headers.cend() == headers.find("Security")); | 374 EXPECT_FALSE(headers.cend() == headers.find("Security")); |
373 } | 375 } |
374 } | 376 } |
OLD | NEW |