| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 void SetUp() | 48 void SetUp() |
| 49 { | 49 { |
| 50 eventCallbackCalled = false; | 50 eventCallbackCalled = false; |
| 51 updateCallbackCalled = false; | 51 updateCallbackCalled = false; |
| 52 } | 52 } |
| 53 | 53 |
| 54 void CreateFilterEngine() | 54 void CreateFilterEngine() |
| 55 { | 55 { |
| 56 JsEngineCreationParameters jsEngineParams; | 56 JsEngineCreationParameters jsEngineParams; |
| 57 jsEngineParams.appInfo = appInfo; | 57 jsEngineParams.appInfo = appInfo; |
| 58 LazyFileSystem* fileSystem; |
| 58 jsEngineParams.logSystem.reset(new LazyLogSystem()); | 59 jsEngineParams.logSystem.reset(new LazyLogSystem()); |
| 59 jsEngineParams.fileSystem.reset(new LazyFileSystem()); | 60 jsEngineParams.fileSystem.reset(fileSystem = new LazyFileSystem()); |
| 60 jsEngineParams.timer = DelayedTimer::New(timerTasks); | 61 jsEngineParams.timer = DelayedTimer::New(timerTasks); |
| 61 jsEngineParams.webRequest = DelayedWebRequest::New(webRequestTasks); | 62 jsEngineParams.webRequest = DelayedWebRequest::New(webRequestTasks); |
| 62 auto jsEngine = CreateJsEngine(std::move(jsEngineParams)); | 63 auto jsEngine = CreateJsEngine(std::move(jsEngineParams)); |
| 63 jsEngine->SetEventCallback("updateAvailable", [this](JsValueList&& params) | 64 jsEngine->SetEventCallback("updateAvailable", [this](JsValueList&& params) |
| 64 { | 65 { |
| 65 eventCallbackCalled = true; | 66 eventCallbackCalled = true; |
| 66 eventCallbackParams = std::move(params); | 67 eventCallbackParams = std::move(params); |
| 67 }); | 68 }); |
| 68 | 69 |
| 69 filterEngine = AdblockPlus::FilterEngine::Create(jsEngine); | 70 filterEngine = ::CreateFilterEngine(*fileSystem, jsEngine); |
| 70 } | 71 } |
| 71 | 72 |
| 72 // Returns a URL or the empty string if there is no such request. | 73 // Returns a URL or the empty string if there is no such request. |
| 73 std::string ProcessPendingUpdateWebRequest() | 74 std::string ProcessPendingUpdateWebRequest() |
| 74 { | 75 { |
| 75 auto ii = webRequestTasks->begin(); | 76 auto ii = webRequestTasks->begin(); |
| 76 while (ii != webRequestTasks->end()) | 77 while (ii != webRequestTasks->end()) |
| 77 { | 78 { |
| 78 if (ii->url.find("update.json") != std::string::npos) | 79 if (ii->url.find("update.json") != std::string::npos) |
| 79 { | 80 { |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 | 300 |
| 300 // ensure that the was the corresponding request | 301 // ensure that the was the corresponding request |
| 301 EXPECT_FALSE(ProcessPendingUpdateWebRequest().empty()); | 302 EXPECT_FALSE(ProcessPendingUpdateWebRequest().empty()); |
| 302 | 303 |
| 303 EXPECT_FALSE(eventCallbackCalled); | 304 EXPECT_FALSE(eventCallbackCalled); |
| 304 EXPECT_EQ(1, timesCalled); | 305 EXPECT_EQ(1, timesCalled); |
| 305 | 306 |
| 306 // previous handler is not restored | 307 // previous handler is not restored |
| 307 EXPECT_FALSE(eventCallbackCalled); | 308 EXPECT_FALSE(eventCallbackCalled); |
| 308 } | 309 } |
| OLD | NEW |