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

Side by Side Diff: test/Prefs.cpp

Issue 29372702: Issue #4826 - Use latch to replace thread-sleeping in tests
Patch Set: stray comments Created Jan. 20, 2017, 1:29 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/LatchTest.cpp ('k') | test/UpdateCheck.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 TEST_F(PrefsTest, PrefsPersist) 144 TEST_F(PrefsTest, PrefsPersist)
145 { 145 {
146 ASSERT_EQ("patterns.ini", filterEngine->GetPref("patternsfile")->AsString()); 146 ASSERT_EQ("patterns.ini", filterEngine->GetPref("patternsfile")->AsString());
147 ASSERT_EQ(24, filterEngine->GetPref("patternsbackupinterval")->AsInt()); 147 ASSERT_EQ(24, filterEngine->GetPref("patternsbackupinterval")->AsInt());
148 ASSERT_TRUE(filterEngine->GetPref("subscriptions_autoupdate")->AsBool()); 148 ASSERT_TRUE(filterEngine->GetPref("subscriptions_autoupdate")->AsBool());
149 149
150 filterEngine->SetPref("patternsfile", jsEngine->NewValue("filters.ini")); 150 filterEngine->SetPref("patternsfile", jsEngine->NewValue("filters.ini"));
151 filterEngine->SetPref("patternsbackupinterval", jsEngine->NewValue(48)); 151 filterEngine->SetPref("patternsbackupinterval", jsEngine->NewValue(48));
152 filterEngine->SetPref("subscriptions_autoupdate", jsEngine->NewValue(false)); 152 filterEngine->SetPref("subscriptions_autoupdate", jsEngine->NewValue(false));
153 153
154 std::this_thread::sleep_for(std::chrono::milliseconds(100)); 154 std::this_thread::sleep_for(std::chrono::milliseconds(100)); // RACE
155 155
156 ASSERT_FALSE(fileSystem->prefsContents.empty()); 156 ASSERT_FALSE(fileSystem->prefsContents.empty());
157 157
158 Reset(); 158 Reset();
159 159
160 ASSERT_EQ("filters.ini", filterEngine->GetPref("patternsfile")->AsString()); 160 ASSERT_EQ("filters.ini", filterEngine->GetPref("patternsfile")->AsString());
161 ASSERT_EQ(48, filterEngine->GetPref("patternsbackupinterval")->AsInt()); 161 ASSERT_EQ(48, filterEngine->GetPref("patternsbackupinterval")->AsInt());
162 ASSERT_FALSE(filterEngine->GetPref("subscriptions_autoupdate")->AsBool()); 162 ASSERT_FALSE(filterEngine->GetPref("subscriptions_autoupdate")->AsBool());
163 } 163 }
164 164
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 TEST_F(PrefsTest, PrefsPersistWhenPreconfigured) 215 TEST_F(PrefsTest, PrefsPersistWhenPreconfigured)
216 { 216 {
217 boolPrefsInitializer preconfiguredPrefs; 217 boolPrefsInitializer preconfiguredPrefs;
218 preconfiguredPrefs["suppress_first_run_page"] = true; 218 preconfiguredPrefs["suppress_first_run_page"] = true;
219 Reset(preconfiguredPrefs); 219 Reset(preconfiguredPrefs);
220 220
221 ASSERT_TRUE(filterEngine->GetPref("suppress_first_run_page")->IsBool()); 221 ASSERT_TRUE(filterEngine->GetPref("suppress_first_run_page")->IsBool());
222 ASSERT_TRUE(filterEngine->GetPref("suppress_first_run_page")->AsBool()); 222 ASSERT_TRUE(filterEngine->GetPref("suppress_first_run_page")->AsBool());
223 filterEngine->SetPref("suppress_first_run_page", jsEngine->NewValue(false)); 223 filterEngine->SetPref("suppress_first_run_page", jsEngine->NewValue(false));
224 224
225 std::this_thread::sleep_for(std::chrono::milliseconds(100)); 225 std::this_thread::sleep_for(std::chrono::milliseconds(100)); // RACE
226 226
227 ASSERT_FALSE(fileSystem->prefsContents.empty()); 227 ASSERT_FALSE(fileSystem->prefsContents.empty());
228 228
229 Reset(preconfiguredPrefs); 229 Reset(preconfiguredPrefs);
230 230
231 ASSERT_TRUE(filterEngine->GetPref("suppress_first_run_page")->IsBool()); 231 ASSERT_TRUE(filterEngine->GetPref("suppress_first_run_page")->IsBool());
232 ASSERT_FALSE(filterEngine->GetPref("suppress_first_run_page")->AsBool()); 232 ASSERT_FALSE(filterEngine->GetPref("suppress_first_run_page")->AsBool());
233 } 233 }
OLDNEW
« no previous file with comments | « test/LatchTest.cpp ('k') | test/UpdateCheck.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld