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

Delta Between Two Patch Sets: test/Prefs.cpp

Issue 29417605: Issue 5034 - Part 3: Create plain JsValue instead of JsValuePtr (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Left Patch Set: Created April 19, 2017, 5:54 p.m.
Right Patch Set: Pass JsEngine by ref Created April 20, 2017, 1:01 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « test/JsValue.cpp ('k') | test/UpdateCheck.cpp » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 { 153 {
154 fileSystem->prefsContents = "{\"patternsbackupinterval\": 6, \"foo\"}"; 154 fileSystem->prefsContents = "{\"patternsbackupinterval\": 6, \"foo\"}";
155 auto filterEngine = CreateFilterEngine(); 155 auto filterEngine = CreateFilterEngine();
156 156
157 ASSERT_EQ(24, filterEngine->GetPref("patternsbackupinterval").AsInt()); 157 ASSERT_EQ(24, filterEngine->GetPref("patternsbackupinterval").AsInt());
158 } 158 }
159 159
160 TEST_F(PrefsTest, PreconfiguredPrefsPreconfigured) 160 TEST_F(PrefsTest, PreconfiguredPrefsPreconfigured)
161 { 161 {
162 AdblockPlus::FilterEngine::Prefs preconfiguredPrefs; 162 AdblockPlus::FilterEngine::Prefs preconfiguredPrefs;
163 preconfiguredPrefs.insert(std::make_pair("disable_auto_updates", jsEngine->New Value(false))); 163 preconfiguredPrefs.emplace("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.
164 preconfiguredPrefs.insert(std::make_pair("suppress_first_run_page", jsEngine-> NewValue(true))); 164 preconfiguredPrefs.emplace("suppress_first_run_page", jsEngine->NewValue(true) );
165 auto filterEngine = CreateFilterEngine(preconfiguredPrefs); 165 auto filterEngine = CreateFilterEngine(preconfiguredPrefs);
166 166
167 ASSERT_TRUE(filterEngine->GetPref("disable_auto_updates").IsBool()); 167 ASSERT_TRUE(filterEngine->GetPref("disable_auto_updates").IsBool());
168 ASSERT_FALSE(filterEngine->GetPref("disable_auto_updates").AsBool()); 168 ASSERT_FALSE(filterEngine->GetPref("disable_auto_updates").AsBool());
169 ASSERT_TRUE(filterEngine->GetPref("suppress_first_run_page").IsBool()); 169 ASSERT_TRUE(filterEngine->GetPref("suppress_first_run_page").IsBool());
170 ASSERT_TRUE(filterEngine->GetPref("suppress_first_run_page").AsBool()); 170 ASSERT_TRUE(filterEngine->GetPref("suppress_first_run_page").AsBool());
171 } 171 }
172 172
173 TEST_F(PrefsTest, PreconfiguredPrefsUnsupported) 173 TEST_F(PrefsTest, PreconfiguredPrefsUnsupported)
174 { 174 {
175 AdblockPlus::FilterEngine::Prefs preconfiguredPrefs; 175 AdblockPlus::FilterEngine::Prefs preconfiguredPrefs;
176 preconfiguredPrefs.insert(std::make_pair("unsupported_preconfig", jsEngine->Ne wValue(true))); 176 preconfiguredPrefs.emplace("unsupported_preconfig", jsEngine->NewValue(true));
177 auto filterEngine = CreateFilterEngine(preconfiguredPrefs); 177 auto filterEngine = CreateFilterEngine(preconfiguredPrefs);
178 178
179 ASSERT_TRUE(filterEngine->GetPref("unsupported_preconfig").IsUndefined()); 179 ASSERT_TRUE(filterEngine->GetPref("unsupported_preconfig").IsUndefined());
180 } 180 }
181 181
182 TEST_F(PrefsTest, PreconfiguredPrefsOverride) 182 TEST_F(PrefsTest, PreconfiguredPrefsOverride)
183 { 183 {
184 AdblockPlus::FilterEngine::Prefs preconfiguredPrefs; 184 AdblockPlus::FilterEngine::Prefs preconfiguredPrefs;
185 preconfiguredPrefs.insert(std::make_pair("suppress_first_run_page", jsEngine-> NewValue(true))); 185 preconfiguredPrefs.emplace("suppress_first_run_page", jsEngine->NewValue(true) );
186 auto filterEngine = CreateFilterEngine(preconfiguredPrefs); 186 auto filterEngine = CreateFilterEngine(preconfiguredPrefs);
187 187
188 filterEngine->SetPref("suppress_first_run_page", jsEngine->NewValue(false)); 188 filterEngine->SetPref("suppress_first_run_page", jsEngine->NewValue(false));
189 ASSERT_TRUE(filterEngine->GetPref("suppress_first_run_page").IsBool()); 189 ASSERT_TRUE(filterEngine->GetPref("suppress_first_run_page").IsBool());
190 ASSERT_FALSE(filterEngine->GetPref("suppress_first_run_page").AsBool()); 190 ASSERT_FALSE(filterEngine->GetPref("suppress_first_run_page").AsBool());
191 } 191 }
192 192
193 TEST_F(PrefsTest, PrefsPersistWhenPreconfigured) 193 TEST_F(PrefsTest, PrefsPersistWhenPreconfigured)
194 { 194 {
195 { 195 {
196 AdblockPlus::FilterEngine::Prefs preconfiguredPrefs; 196 AdblockPlus::FilterEngine::Prefs preconfiguredPrefs;
197 preconfiguredPrefs.insert(std::make_pair("suppress_first_run_page", jsEngine ->NewValue(true))); 197 preconfiguredPrefs.emplace("suppress_first_run_page", jsEngine->NewValue(tru e));
198 auto filterEngine = CreateFilterEngine(preconfiguredPrefs); 198 auto filterEngine = CreateFilterEngine(preconfiguredPrefs);
199 199
200 ASSERT_TRUE(filterEngine->GetPref("suppress_first_run_page").IsBool()); 200 ASSERT_TRUE(filterEngine->GetPref("suppress_first_run_page").IsBool());
201 ASSERT_TRUE(filterEngine->GetPref("suppress_first_run_page").AsBool()); 201 ASSERT_TRUE(filterEngine->GetPref("suppress_first_run_page").AsBool());
202 filterEngine->SetPref("suppress_first_run_page", jsEngine->NewValue(false)); 202 filterEngine->SetPref("suppress_first_run_page", jsEngine->NewValue(false));
203 203
204 AdblockPlus::Sleep(100); 204 AdblockPlus::Sleep(100);
205 } 205 }
206 ASSERT_FALSE(fileSystem->prefsContents.empty()); 206 ASSERT_FALSE(fileSystem->prefsContents.empty());
207 207
208 { 208 {
209 ResetJsEngine(); 209 ResetJsEngine();
210 AdblockPlus::FilterEngine::Prefs preconfiguredPrefs; 210 AdblockPlus::FilterEngine::Prefs preconfiguredPrefs;
211 preconfiguredPrefs.insert(std::make_pair("suppress_first_run_page", jsEngine ->NewValue(true))); 211 preconfiguredPrefs.emplace("suppress_first_run_page", jsEngine->NewValue(tru e));
212 auto filterEngine = CreateFilterEngine(preconfiguredPrefs); 212 auto filterEngine = CreateFilterEngine(preconfiguredPrefs);
213 213
214 ASSERT_TRUE(filterEngine->GetPref("suppress_first_run_page").IsBool()); 214 ASSERT_TRUE(filterEngine->GetPref("suppress_first_run_page").IsBool());
215 ASSERT_FALSE(filterEngine->GetPref("suppress_first_run_page").AsBool()); 215 ASSERT_FALSE(filterEngine->GetPref("suppress_first_run_page").AsBool());
216 } 216 }
217 } 217 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld