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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 previousRequestUrl = url; | 44 previousRequestUrl = url; |
45 return response; | 45 return response; |
46 } | 46 } |
47 }; | 47 }; |
48 | 48 |
49 class UpdateCheckTest : public ::testing::Test | 49 class UpdateCheckTest : public ::testing::Test |
50 { | 50 { |
51 protected: | 51 protected: |
52 AdblockPlus::AppInfo appInfo; | 52 AdblockPlus::AppInfo appInfo; |
53 TestWebRequest* webRequest; | 53 std::shared_ptr<TestWebRequest> webRequest; |
54 WebRequestSharedPtr webRequestPtr; | |
55 AdblockPlus::JsEnginePtr jsEngine; | 54 AdblockPlus::JsEnginePtr jsEngine; |
56 FilterEnginePtr filterEngine; | 55 FilterEnginePtr filterEngine; |
57 | 56 |
58 bool eventCallbackCalled; | 57 bool eventCallbackCalled; |
59 AdblockPlus::JsValueList eventCallbackParams; | 58 AdblockPlus::JsValueList eventCallbackParams; |
60 bool updateCallbackCalled; | 59 bool updateCallbackCalled; |
61 std::string updateError; | 60 std::string updateError; |
62 | 61 |
63 void SetUp() | 62 void SetUp() |
64 { | 63 { |
65 webRequest = new TestWebRequest(); | 64 webRequest = std::make_shared<TestWebRequest>(); |
66 webRequestPtr.reset(webRequest); | |
67 | 65 |
68 eventCallbackCalled = false; | 66 eventCallbackCalled = false; |
69 updateCallbackCalled = false; | 67 updateCallbackCalled = false; |
70 Reset(); | 68 Reset(); |
71 } | 69 } |
72 | 70 |
73 void Reset() | 71 void Reset() |
74 { | 72 { |
75 jsEngine = CreateJsEngine(appInfo); | 73 JsEngineCreationParameters jsEngineParams; |
76 jsEngine->SetLogSystem(AdblockPlus::LogSystemPtr(new LazyLogSystem)); | 74 jsEngineParams.appInfo = appInfo; |
77 jsEngine->SetFileSystem(AdblockPlus::FileSystemPtr(new LazyFileSystem)); | 75 jsEngineParams.logSystem.reset(new LazyLogSystem()); |
78 jsEngine->SetWebRequest(webRequestPtr); | 76 jsEngineParams.fileSystem.reset(new LazyFileSystem()); |
| 77 jsEngineParams.timer = CreateDefaultTimer(); |
| 78 jsEngine = CreateJsEngine(std::move(jsEngineParams)); |
| 79 jsEngine->SetWebRequest(webRequest); |
79 jsEngine->SetEventCallback("updateAvailable", [this](JsValueList&& params) | 80 jsEngine->SetEventCallback("updateAvailable", [this](JsValueList&& params) |
80 { | 81 { |
81 eventCallbackCalled = true; | 82 eventCallbackCalled = true; |
82 eventCallbackParams = std::move(params); | 83 eventCallbackParams = std::move(params); |
83 }); | 84 }); |
84 | 85 |
85 filterEngine = AdblockPlus::FilterEngine::Create(jsEngine); | 86 filterEngine = AdblockPlus::FilterEngine::Create(jsEngine); |
86 } | 87 } |
87 | 88 |
88 void ForceUpdateCheck() | 89 void ForceUpdateCheck() |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 | 256 |
256 Reset(); | 257 Reset(); |
257 ForceUpdateCheck(); | 258 ForceUpdateCheck(); |
258 | 259 |
259 AdblockPlus::Sleep(100); | 260 AdblockPlus::Sleep(100); |
260 | 261 |
261 ASSERT_FALSE(eventCallbackCalled); | 262 ASSERT_FALSE(eventCallbackCalled); |
262 ASSERT_TRUE(updateCallbackCalled); | 263 ASSERT_TRUE(updateCallbackCalled); |
263 ASSERT_FALSE(updateError.empty()); | 264 ASSERT_FALSE(updateError.empty()); |
264 } | 265 } |
OLD | NEW |