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

Unified Diff: test/Prefs.cpp

Issue 29417605: Issue 5034 - Part 3: Create plain JsValue instead of JsValuePtr (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Added value test for copy ctor Created April 20, 2017, 12:40 p.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
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.emplace("disable_auto_updates", jsEngine->NewValue(false));
+ preconfiguredPrefs.emplace("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.emplace("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.emplace("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.emplace("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.emplace("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());
}
}
« test/JsEngine.cpp ('K') | « test/JsValue.cpp ('k') | test/UpdateCheck.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld