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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 #include <sstream> | 18 #include <sstream> |
19 #include "BaseJsTest.h" | 19 #include "BaseJsTest.h" |
20 #include "../src/Thread.h" | 20 #include "../src/Thread.h" |
| 21 #include "../src/DefaultWebRequest.h" |
21 #include <atomic> | 22 #include <atomic> |
22 #include <mutex> | 23 #include <mutex> |
23 | 24 |
24 using namespace AdblockPlus; | 25 using namespace AdblockPlus; |
25 | 26 |
26 namespace | 27 namespace |
27 { | 28 { |
| 29 WebRequestPtr CreateDefaultWebRequest(const Scheduler& scheduler) |
| 30 { |
| 31 return WebRequestPtr(new DefaultWebRequest(scheduler, WebRequestSyncPtr(new
DefaultWebRequestSync()))); |
| 32 } |
28 class BaseWebRequestTest : public BaseJsTest | 33 class BaseWebRequestTest : public BaseJsTest |
29 { | 34 { |
30 protected: | 35 protected: |
31 void SetUp() | 36 void SetUp() |
32 { | 37 { |
33 ThrowingPlatformCreationParameters platformParams; | 38 ThrowingPlatformCreationParameters platformParams; |
34 platformParams.logSystem = CreateLogSystem(); | 39 platformParams.logSystem = CreateLogSystem(); |
35 platformParams.timer.reset(new NoopTimer()); | 40 platformParams.timer.reset(new NoopTimer()); |
36 platformParams.fileSystem.reset(fileSystem = new LazyFileSystem()); | 41 platformParams.fileSystem.reset(fileSystem = new LazyFileSystem()); |
37 platformParams.webRequest = CreateWebRequest(); | 42 platformParams.webRequest = CreateWebRequest(); |
38 platform.reset(new Platform(std::move(platformParams))); | 43 platform.reset(new Platform(std::move(platformParams))); |
39 } | 44 } |
40 | 45 |
41 virtual WebRequestPtr CreateWebRequest() = 0; | 46 virtual WebRequestPtr CreateWebRequest() = 0; |
42 | 47 |
43 virtual LogSystemPtr CreateLogSystem() | 48 virtual LogSystemPtr CreateLogSystem() |
44 { | 49 { |
45 return LogSystemPtr(new ThrowingLogSystem()); | 50 return LogSystemPtr(new ThrowingLogSystem()); |
46 } | 51 } |
47 | 52 |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 EXPECT_EQ(AdblockPlus::LogSystem::LOG_LEVEL_TRACE, catchLogSystem->lastLogLeve
l); | 376 EXPECT_EQ(AdblockPlus::LogSystem::LOG_LEVEL_TRACE, catchLogSystem->lastLogLeve
l); |
372 EXPECT_EQ("", catchLogSystem->lastMessage); | 377 EXPECT_EQ("", catchLogSystem->lastMessage); |
373 ProcessPendingWebRequests(); | 378 ProcessPendingWebRequests(); |
374 { | 379 { |
375 auto headersRequest = GetHeadersForRequest(url); | 380 auto headersRequest = GetHeadersForRequest(url); |
376 EXPECT_TRUE(headersRequest.first); | 381 EXPECT_TRUE(headersRequest.first); |
377 const auto& headers = headersRequest.second; | 382 const auto& headers = headersRequest.second; |
378 EXPECT_FALSE(headers.cend() == headers.find("Security")); | 383 EXPECT_FALSE(headers.cend() == headers.find("Security")); |
379 } | 384 } |
380 } | 385 } |
OLD | NEW |