| 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-2016 Eyeo GmbH | 3  * Copyright (C) 2006-2016 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 | 19 | 
| 20 #include "../src/Thread.h" |  | 
| 21 #include "BaseJsTest.h" | 20 #include "BaseJsTest.h" | 
| 22 | 21 | 
| 23 namespace | 22 namespace | 
| 24 { | 23 { | 
| 25   typedef std::shared_ptr<AdblockPlus::FilterEngine> FilterEnginePtr; | 24   typedef std::shared_ptr<AdblockPlus::FilterEngine> FilterEnginePtr; | 
| 26 | 25 | 
| 27   class TestFileSystem : public LazyFileSystem | 26   class TestFileSystem : public LazyFileSystem | 
| 28   { | 27   { | 
| 29   public: | 28   public: | 
| 30     std::string prefsContents; | 29     std::string prefsContents; | 
| (...skipping 27 matching lines...) Expand all  Loading... | 
| 58         return result; | 57         return result; | 
| 59       } | 58       } | 
| 60 | 59 | 
| 61       return LazyFileSystem::Stat(path); | 60       return LazyFileSystem::Stat(path); | 
| 62     } | 61     } | 
| 63   }; | 62   }; | 
| 64 | 63 | 
| 65   class PrefsTest : public ::testing::Test | 64   class PrefsTest : public ::testing::Test | 
| 66   { | 65   { | 
| 67   protected: | 66   protected: | 
| 68     TestFileSystem* fileSystem; | 67     std::shared_ptr<TestFileSystem> fileSystem; | 
| 69     AdblockPlus::FileSystemPtr fileSystemPtr; |  | 
| 70     AdblockPlus::JsEnginePtr jsEngine; | 68     AdblockPlus::JsEnginePtr jsEngine; | 
| 71     FilterEnginePtr filterEngine; | 69     FilterEnginePtr filterEngine; | 
| 72 | 70 | 
| 73     void SetUp() | 71     void SetUp() | 
| 74     { | 72     { | 
| 75       fileSystem = new TestFileSystem(); | 73       fileSystem = std::make_shared<TestFileSystem>(); | 
| 76       fileSystemPtr.reset(fileSystem); |  | 
| 77 |  | 
| 78       Reset(); | 74       Reset(); | 
| 79     } | 75     } | 
| 80 | 76 | 
| 81     void Reset(const AdblockPlus::FilterEngine::Prefs& preconfiguredPrefs = | 77     void Reset(const AdblockPlus::FilterEngine::Prefs& preconfiguredPrefs = | 
| 82                AdblockPlus::FilterEngine::Prefs()) | 78                AdblockPlus::FilterEngine::Prefs()) | 
| 83     { | 79     { | 
| 84       jsEngine = CreateJsEngine(); | 80       jsEngine = CreateJsEngine(); | 
| 85       jsEngine->SetLogSystem(AdblockPlus::LogSystemPtr(new LazyLogSystem)); | 81       jsEngine->SetLogSystem(AdblockPlus::LogSystemPtr(new LazyLogSystem)); | 
| 86       jsEngine->SetFileSystem(fileSystemPtr); | 82       jsEngine->SetFileSystem(fileSystem); | 
| 87       jsEngine->SetWebRequest(AdblockPlus::WebRequestPtr(new LazyWebRequest)); | 83       jsEngine->SetWebRequest(AdblockPlus::WebRequestPtr(new LazyWebRequest)); | 
| 88 | 84 | 
| 89       filterEngine.reset( | 85       filterEngine.reset( | 
| 90         new AdblockPlus::FilterEngine(jsEngine, preconfiguredPrefs)); | 86         new AdblockPlus::FilterEngine(jsEngine, preconfiguredPrefs)); | 
| 91     } | 87     } | 
| 92   }; | 88   }; | 
| 93 } | 89 } | 
| 94 | 90 | 
| 95 TEST_F(PrefsTest, PrefsGetSet) | 91 TEST_F(PrefsTest, PrefsGetSet) | 
| 96 { | 92 { | 
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 195 | 191 | 
| 196   std::this_thread::sleep_for(std::chrono::milliseconds(100)); | 192   std::this_thread::sleep_for(std::chrono::milliseconds(100)); | 
| 197 | 193 | 
| 198   ASSERT_FALSE(fileSystem->prefsContents.empty()); | 194   ASSERT_FALSE(fileSystem->prefsContents.empty()); | 
| 199 | 195 | 
| 200   Reset(preconfiguredPrefs); | 196   Reset(preconfiguredPrefs); | 
| 201 | 197 | 
| 202   ASSERT_TRUE(filterEngine->GetPref("suppress_first_run_page")->IsBool()); | 198   ASSERT_TRUE(filterEngine->GetPref("suppress_first_run_page")->IsBool()); | 
| 203   ASSERT_FALSE(filterEngine->GetPref("suppress_first_run_page")->AsBool()); | 199   ASSERT_FALSE(filterEngine->GetPref("suppress_first_run_page")->AsBool()); | 
| 204 } | 200 } | 
| OLD | NEW | 
|---|