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: Simplify the setting of global property. Add more tests. Created June 12, 2015, 7:33 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
« src/JsEngine.cpp ('K') | « 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(std::map<std::string, AdblockPlus::JsValuePtr> preconfiguredPrefs =
sergei 2015/06/19 10:07:15 Why not to use `const Prefs&` in this file and in
Oleksandr 2015/06/22 07:47:08 Done.
+ std::map<std::string, AdblockPlus::JsValuePtr>())
{
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,33 @@
ASSERT_EQ(24, filterEngine->GetPref("patternsbackupinterval")->AsInt());
}
+
+TEST_F(PrefsTest, PreconfiguredPrefsPreconfigured)
+{
+ std::map<std::string, AdblockPlus::JsValuePtr> preconfiguredPrefs;
+ preconfiguredPrefs["disable_auto_updates"] = jsEngine->NewValue(false);
+ preconfiguredPrefs["suppress_first_run_page"] = jsEngine->NewValue(true);
+ Reset(preconfiguredPrefs);
+
+ ASSERT_FALSE(filterEngine->GetPref("disable_auto_updates")->AsBool());
+ ASSERT_TRUE(filterEngine->GetPref("suppress_first_run_page")->AsBool());
+}
+
+TEST_F(PrefsTest, PreconfiguredPrefsUnsupported)
+{
+ std::map<std::string, AdblockPlus::JsValuePtr> preconfiguredPrefs;
+ preconfiguredPrefs["unsupported_preconfig"] = jsEngine->NewValue(true);
+ Reset(preconfiguredPrefs);
+
+ ASSERT_FALSE(filterEngine->GetPref("unsupported_preconfig")->AsBool());
+}
+
+TEST_F(PrefsTest, PreconfiguredPrefsPreconfiguredOverride)
Felix Dahlke 2015/06/12 08:04:20 Micro nit: Seems redundant, "PreconfiguredPrefsOve
Oleksandr 2015/06/12 10:47:57 Done.
+{
+ std::map<std::string, AdblockPlus::JsValuePtr> preconfiguredPrefs;
+ preconfiguredPrefs["suppress_first_run_page"] = jsEngine->NewValue(true);
+ Reset(preconfiguredPrefs);
+
+ filterEngine->SetPref("suppress_first_run_page", jsEngine->NewValue(false));
+ ASSERT_FALSE(filterEngine->GetPref("suppress_first_run_page")->AsBool());
+}
« src/JsEngine.cpp ('K') | « test/JsEngine.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld