Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: test/Prefs.cpp

Issue 5653480979038208: Issue 2325 - Add a way to set settings in libadblockplus for FRP and automatic updates (Closed)
Patch Set: Address more comments Created June 22, 2015, 7:45 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/JsEngine.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/Prefs.cpp
===================================================================
--- a/test/Prefs.cpp
+++ b/test/Prefs.cpp
@@ -78,14 +78,16 @@
Reset();
}
- void Reset()
+ void Reset(const AdblockPlus::FilterEngine::Prefs& preconfiguredPrefs =
+ AdblockPlus::FilterEngine::Prefs())
{
jsEngine = AdblockPlus::JsEngine::New();
jsEngine->SetLogSystem(AdblockPlus::LogSystemPtr(new LazyLogSystem));
jsEngine->SetFileSystem(fileSystemPtr);
jsEngine->SetWebRequest(AdblockPlus::WebRequestPtr(new LazyWebRequest));
- filterEngine.reset(new AdblockPlus::FilterEngine(jsEngine));
+ filterEngine.reset(
+ new AdblockPlus::FilterEngine(jsEngine, preconfiguredPrefs));
}
};
}
@@ -147,3 +149,56 @@
ASSERT_EQ(24, filterEngine->GetPref("patternsbackupinterval")->AsInt());
}
+
+TEST_F(PrefsTest, PreconfiguredPrefsPreconfigured)
+{
+ AdblockPlus::FilterEngine::Prefs preconfiguredPrefs;
+ preconfiguredPrefs["disable_auto_updates"] = jsEngine->NewValue(false);
+ preconfiguredPrefs["suppress_first_run_page"] = jsEngine->NewValue(true);
+ Reset(preconfiguredPrefs);
+
+ ASSERT_TRUE(filterEngine->GetPref("disable_auto_updates")->IsBool());
+ ASSERT_FALSE(filterEngine->GetPref("disable_auto_updates")->AsBool());
+ ASSERT_TRUE(filterEngine->GetPref("suppress_first_run_page")->IsBool());
+ ASSERT_TRUE(filterEngine->GetPref("suppress_first_run_page")->AsBool());
+}
+
+TEST_F(PrefsTest, PreconfiguredPrefsUnsupported)
+{
+ AdblockPlus::FilterEngine::Prefs preconfiguredPrefs;
+ preconfiguredPrefs["unsupported_preconfig"] = jsEngine->NewValue(true);
+ Reset(preconfiguredPrefs);
+
+ ASSERT_TRUE(filterEngine->GetPref("unsupported_preconfig")->IsUndefined());
+}
+
+TEST_F(PrefsTest, PreconfiguredPrefsOverride)
+{
+ AdblockPlus::FilterEngine::Prefs preconfiguredPrefs;
+ preconfiguredPrefs["suppress_first_run_page"] = jsEngine->NewValue(true);
+ Reset(preconfiguredPrefs);
+
+ filterEngine->SetPref("suppress_first_run_page", jsEngine->NewValue(false));
+ ASSERT_TRUE(filterEngine->GetPref("suppress_first_run_page")->IsBool());
+ ASSERT_FALSE(filterEngine->GetPref("suppress_first_run_page")->AsBool());
+}
+
+TEST_F(PrefsTest, PrefsPersistWhenPreconfigured)
+{
+ AdblockPlus::FilterEngine::Prefs preconfiguredPrefs;
+ preconfiguredPrefs["suppress_first_run_page"] = jsEngine->NewValue(true);
+ Reset(preconfiguredPrefs);
+
+ ASSERT_TRUE(filterEngine->GetPref("suppress_first_run_page")->IsBool());
+ ASSERT_TRUE(filterEngine->GetPref("suppress_first_run_page")->AsBool());
+ filterEngine->SetPref("suppress_first_run_page", jsEngine->NewValue(false));
+
+ AdblockPlus::Sleep(100);
+
+ ASSERT_FALSE(fileSystem->prefsContents.empty());
+
+ Reset(preconfiguredPrefs);
+
+ ASSERT_TRUE(filterEngine->GetPref("suppress_first_run_page")->IsBool());
+ ASSERT_FALSE(filterEngine->GetPref("suppress_first_run_page")->AsBool());
+}
« no previous file with comments | « test/JsEngine.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld