Index: test/Prefs.cpp |
=================================================================== |
--- a/test/Prefs.cpp |
+++ b/test/Prefs.cpp |
@@ -93,125 +93,125 @@ |
return AdblockPlus::FilterEngine::Create(jsEngine, createParams); |
} |
}; |
} |
TEST_F(PrefsTest, PrefsGetSet) |
{ |
auto filterEngine = CreateFilterEngine(); |
- ASSERT_EQ("patterns.ini", filterEngine->GetPref("patternsfile")->AsString()); |
- ASSERT_EQ(24, filterEngine->GetPref("patternsbackupinterval")->AsInt()); |
- ASSERT_TRUE(filterEngine->GetPref("subscriptions_autoupdate")->AsBool()); |
- ASSERT_TRUE(filterEngine->GetPref("foobar")->IsUndefined()); |
+ ASSERT_EQ("patterns.ini", filterEngine->GetPref("patternsfile").AsString()); |
+ ASSERT_EQ(24, filterEngine->GetPref("patternsbackupinterval").AsInt()); |
+ ASSERT_TRUE(filterEngine->GetPref("subscriptions_autoupdate").AsBool()); |
+ ASSERT_TRUE(filterEngine->GetPref("foobar").IsUndefined()); |
ASSERT_ANY_THROW(filterEngine->SetPref("patternsfile", jsEngine->NewValue(0))); |
ASSERT_ANY_THROW(filterEngine->SetPref("patternsbackupinterval", jsEngine->NewValue(true))); |
ASSERT_ANY_THROW(filterEngine->SetPref("subscriptions_autoupdate", jsEngine->NewValue("foo"))); |
filterEngine->SetPref("patternsfile", jsEngine->NewValue("filters.ini")); |
filterEngine->SetPref("patternsbackupinterval", jsEngine->NewValue(48)); |
filterEngine->SetPref("subscriptions_autoupdate", jsEngine->NewValue(false)); |
- ASSERT_EQ("filters.ini", filterEngine->GetPref("patternsfile")->AsString()); |
- ASSERT_EQ(48, filterEngine->GetPref("patternsbackupinterval")->AsInt()); |
- ASSERT_FALSE(filterEngine->GetPref("subscriptions_autoupdate")->AsBool()); |
+ ASSERT_EQ("filters.ini", filterEngine->GetPref("patternsfile").AsString()); |
+ ASSERT_EQ(48, filterEngine->GetPref("patternsbackupinterval").AsInt()); |
+ ASSERT_FALSE(filterEngine->GetPref("subscriptions_autoupdate").AsBool()); |
} |
TEST_F(PrefsTest, PrefsPersist) |
{ |
{ |
auto filterEngine = CreateFilterEngine(); |
- ASSERT_EQ("patterns.ini", filterEngine->GetPref("patternsfile")->AsString()); |
- ASSERT_EQ(24, filterEngine->GetPref("patternsbackupinterval")->AsInt()); |
- ASSERT_TRUE(filterEngine->GetPref("subscriptions_autoupdate")->AsBool()); |
+ ASSERT_EQ("patterns.ini", filterEngine->GetPref("patternsfile").AsString()); |
+ ASSERT_EQ(24, filterEngine->GetPref("patternsbackupinterval").AsInt()); |
+ ASSERT_TRUE(filterEngine->GetPref("subscriptions_autoupdate").AsBool()); |
filterEngine->SetPref("patternsfile", jsEngine->NewValue("filters.ini")); |
filterEngine->SetPref("patternsbackupinterval", jsEngine->NewValue(48)); |
filterEngine->SetPref("subscriptions_autoupdate", jsEngine->NewValue(false)); |
AdblockPlus::Sleep(100); |
} |
ASSERT_FALSE(fileSystem->prefsContents.empty()); |
{ |
ResetJsEngine(); |
auto filterEngine = CreateFilterEngine(); |
- ASSERT_EQ("filters.ini", filterEngine->GetPref("patternsfile")->AsString()); |
- ASSERT_EQ(48, filterEngine->GetPref("patternsbackupinterval")->AsInt()); |
- ASSERT_FALSE(filterEngine->GetPref("subscriptions_autoupdate")->AsBool()); |
+ ASSERT_EQ("filters.ini", filterEngine->GetPref("patternsfile").AsString()); |
+ ASSERT_EQ(48, filterEngine->GetPref("patternsbackupinterval").AsInt()); |
+ ASSERT_FALSE(filterEngine->GetPref("subscriptions_autoupdate").AsBool()); |
} |
} |
TEST_F(PrefsTest, UnknownPrefs) |
{ |
fileSystem->prefsContents = "{\"foobar\":2, \"patternsbackupinterval\": 12}"; |
auto filterEngine = CreateFilterEngine(); |
- ASSERT_TRUE(filterEngine->GetPref("foobar")->IsUndefined()); |
- ASSERT_EQ(12, filterEngine->GetPref("patternsbackupinterval")->AsInt()); |
+ ASSERT_TRUE(filterEngine->GetPref("foobar").IsUndefined()); |
+ ASSERT_EQ(12, filterEngine->GetPref("patternsbackupinterval").AsInt()); |
} |
TEST_F(PrefsTest, SyntaxFailure) |
{ |
fileSystem->prefsContents = "{\"patternsbackupinterval\": 6, \"foo\"}"; |
auto filterEngine = CreateFilterEngine(); |
- ASSERT_EQ(24, filterEngine->GetPref("patternsbackupinterval")->AsInt()); |
+ 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); |
+ preconfiguredPrefs.insert(std::make_pair("disable_auto_updates", jsEngine->NewValue(false))); |
sergei
2017/04/19 18:56:52
emplace in this file could also a bit reduce the c
hub
2017/04/19 21:56:49
Done.
|
+ preconfiguredPrefs.insert(std::make_pair("suppress_first_run_page", jsEngine->NewValue(true))); |
auto filterEngine = CreateFilterEngine(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()); |
+ 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); |
+ preconfiguredPrefs.insert(std::make_pair("unsupported_preconfig", jsEngine->NewValue(true))); |
auto filterEngine = CreateFilterEngine(preconfiguredPrefs); |
- ASSERT_TRUE(filterEngine->GetPref("unsupported_preconfig")->IsUndefined()); |
+ ASSERT_TRUE(filterEngine->GetPref("unsupported_preconfig").IsUndefined()); |
} |
TEST_F(PrefsTest, PreconfiguredPrefsOverride) |
{ |
AdblockPlus::FilterEngine::Prefs preconfiguredPrefs; |
- preconfiguredPrefs["suppress_first_run_page"] = jsEngine->NewValue(true); |
+ preconfiguredPrefs.insert(std::make_pair("suppress_first_run_page", jsEngine->NewValue(true))); |
auto filterEngine = CreateFilterEngine(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()); |
+ 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); |
+ preconfiguredPrefs.insert(std::make_pair("suppress_first_run_page", jsEngine->NewValue(true))); |
auto filterEngine = CreateFilterEngine(preconfiguredPrefs); |
- ASSERT_TRUE(filterEngine->GetPref("suppress_first_run_page")->IsBool()); |
- ASSERT_TRUE(filterEngine->GetPref("suppress_first_run_page")->AsBool()); |
+ 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()); |
{ |
ResetJsEngine(); |
AdblockPlus::FilterEngine::Prefs preconfiguredPrefs; |
- preconfiguredPrefs["suppress_first_run_page"] = jsEngine->NewValue(true); |
+ preconfiguredPrefs.insert(std::make_pair("suppress_first_run_page", jsEngine->NewValue(true))); |
auto filterEngine = CreateFilterEngine(preconfiguredPrefs); |
- ASSERT_TRUE(filterEngine->GetPref("suppress_first_run_page")->IsBool()); |
- ASSERT_FALSE(filterEngine->GetPref("suppress_first_run_page")->AsBool()); |
+ ASSERT_TRUE(filterEngine->GetPref("suppress_first_run_page").IsBool()); |
+ ASSERT_FALSE(filterEngine->GetPref("suppress_first_run_page").AsBool()); |
} |
} |