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: Added a unit test. Changed the global object injection routine. Created June 10, 2015, 8:42 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') | « src/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 =
+ 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,16 @@
ASSERT_EQ(24, filterEngine->GetPref("patternsbackupinterval")->AsInt());
}
+
+TEST_F(PrefsTest, PreconfiguredPrefs)
+{
+ std::map<std::string, AdblockPlus::JsValuePtr> preconfiguredPrefs;
+ preconfiguredPrefs["disable_auto_updates"] = jsEngine->NewValue(false);
+ preconfiguredPrefs["suppress_first_run_page"] = jsEngine->NewValue(true);
+ preconfiguredPrefs["unsupported_preconfig"] = jsEngine->NewValue(true);
+ Reset(preconfiguredPrefs);
+
+ ASSERT_FALSE(filterEngine->GetPref("disable_auto_updates")->AsBool());
+ ASSERT_TRUE(filterEngine->GetPref("suppress_first_run_page")->AsBool());
+ ASSERT_FALSE(filterEngine->GetPref("unsupported_preconfig")->AsBool());
Eric 2015/06/10 17:48:16 This assertion should really be in a separate test
Oleksandr 2015/06/12 10:47:57 Done.
+}
Eric 2015/06/10 17:48:16 With preconfigurable preferences, we now have thre
Oleksandr 2015/06/12 07:36:14 I think (a) and (a) and (c) are tested quite well
Felix Dahlke 2015/06/12 07:55:03 Most of that is covered here, but I think we shoul
Oleksandr 2015/06/12 10:47:57 Done. That's a great test, actually. Revealed one
« src/JsEngine.cpp ('K') | « src/JsEngine.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld