| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/sync/test/integration/preferences_helper.h" | 5 #include "chrome/browser/sync/test/integration/preferences_helper.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_change_registrar.h" | 7 #include "base/prefs/pref_change_registrar.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/prefs/scoped_user_pref_update.h" | 9 #include "base/prefs/scoped_user_pref_update.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 | 213 |
| 214 namespace { | 214 namespace { |
| 215 | 215 |
| 216 class PrefMatchChecker : public StatusChangeChecker { | 216 class PrefMatchChecker : public StatusChangeChecker { |
| 217 public: | 217 public: |
| 218 explicit PrefMatchChecker(const char* path); | 218 explicit PrefMatchChecker(const char* path); |
| 219 virtual ~PrefMatchChecker(); | 219 virtual ~PrefMatchChecker(); |
| 220 | 220 |
| 221 // StatusChangeChecker implementation. | 221 // StatusChangeChecker implementation. |
| 222 virtual bool IsExitConditionSatisfied() = 0; | 222 virtual bool IsExitConditionSatisfied() = 0; |
| 223 virtual std::string GetDebugMessage() const OVERRIDE; | 223 virtual std::string GetDebugMessage() const override; |
| 224 | 224 |
| 225 // Wait for condition to become true. | 225 // Wait for condition to become true. |
| 226 void Wait(); | 226 void Wait(); |
| 227 | 227 |
| 228 protected: | 228 protected: |
| 229 const char* GetPath() const; | 229 const char* GetPath() const; |
| 230 | 230 |
| 231 private: | 231 private: |
| 232 void RegisterPrefListener(PrefService* pref_service); | 232 void RegisterPrefListener(PrefService* pref_service); |
| 233 | 233 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 pref_change_registrars_.push_back(registrar.release()); | 274 pref_change_registrars_.push_back(registrar.release()); |
| 275 } | 275 } |
| 276 | 276 |
| 277 // Helper class used in the implementation of AwaitListPrefMatches. | 277 // Helper class used in the implementation of AwaitListPrefMatches. |
| 278 class ListPrefMatchChecker : public PrefMatchChecker { | 278 class ListPrefMatchChecker : public PrefMatchChecker { |
| 279 public: | 279 public: |
| 280 explicit ListPrefMatchChecker(const char* path); | 280 explicit ListPrefMatchChecker(const char* path); |
| 281 virtual ~ListPrefMatchChecker(); | 281 virtual ~ListPrefMatchChecker(); |
| 282 | 282 |
| 283 // Implementation of PrefMatchChecker. | 283 // Implementation of PrefMatchChecker. |
| 284 virtual bool IsExitConditionSatisfied() OVERRIDE; | 284 virtual bool IsExitConditionSatisfied() override; |
| 285 }; | 285 }; |
| 286 | 286 |
| 287 ListPrefMatchChecker::ListPrefMatchChecker(const char* path) | 287 ListPrefMatchChecker::ListPrefMatchChecker(const char* path) |
| 288 : PrefMatchChecker(path) { | 288 : PrefMatchChecker(path) { |
| 289 } | 289 } |
| 290 | 290 |
| 291 ListPrefMatchChecker::~ListPrefMatchChecker() { | 291 ListPrefMatchChecker::~ListPrefMatchChecker() { |
| 292 } | 292 } |
| 293 | 293 |
| 294 bool ListPrefMatchChecker::IsExitConditionSatisfied() { | 294 bool ListPrefMatchChecker::IsExitConditionSatisfied() { |
| 295 return ListPrefMatches(GetPath()); | 295 return ListPrefMatches(GetPath()); |
| 296 } | 296 } |
| 297 | 297 |
| 298 // Helper class used in the implementation of AwaitBooleanPrefMatches. | 298 // Helper class used in the implementation of AwaitBooleanPrefMatches. |
| 299 class BooleanPrefMatchChecker : public PrefMatchChecker { | 299 class BooleanPrefMatchChecker : public PrefMatchChecker { |
| 300 public: | 300 public: |
| 301 explicit BooleanPrefMatchChecker(const char* path); | 301 explicit BooleanPrefMatchChecker(const char* path); |
| 302 virtual ~BooleanPrefMatchChecker(); | 302 virtual ~BooleanPrefMatchChecker(); |
| 303 | 303 |
| 304 // Implementation of PrefMatchChecker. | 304 // Implementation of PrefMatchChecker. |
| 305 virtual bool IsExitConditionSatisfied() OVERRIDE; | 305 virtual bool IsExitConditionSatisfied() override; |
| 306 }; | 306 }; |
| 307 | 307 |
| 308 BooleanPrefMatchChecker::BooleanPrefMatchChecker(const char* path) | 308 BooleanPrefMatchChecker::BooleanPrefMatchChecker(const char* path) |
| 309 : PrefMatchChecker(path) { | 309 : PrefMatchChecker(path) { |
| 310 } | 310 } |
| 311 | 311 |
| 312 BooleanPrefMatchChecker::~BooleanPrefMatchChecker() { | 312 BooleanPrefMatchChecker::~BooleanPrefMatchChecker() { |
| 313 } | 313 } |
| 314 | 314 |
| 315 bool BooleanPrefMatchChecker::IsExitConditionSatisfied() { | 315 bool BooleanPrefMatchChecker::IsExitConditionSatisfied() { |
| 316 return BooleanPrefMatches(GetPath()); | 316 return BooleanPrefMatches(GetPath()); |
| 317 } | 317 } |
| 318 | 318 |
| 319 // Helper class used in the implementation of AwaitIntegerPrefMatches. | 319 // Helper class used in the implementation of AwaitIntegerPrefMatches. |
| 320 class IntegerPrefMatchChecker : public PrefMatchChecker { | 320 class IntegerPrefMatchChecker : public PrefMatchChecker { |
| 321 public: | 321 public: |
| 322 explicit IntegerPrefMatchChecker(const char* path); | 322 explicit IntegerPrefMatchChecker(const char* path); |
| 323 virtual ~IntegerPrefMatchChecker(); | 323 virtual ~IntegerPrefMatchChecker(); |
| 324 | 324 |
| 325 // Implementation of PrefMatchChecker. | 325 // Implementation of PrefMatchChecker. |
| 326 virtual bool IsExitConditionSatisfied() OVERRIDE; | 326 virtual bool IsExitConditionSatisfied() override; |
| 327 }; | 327 }; |
| 328 | 328 |
| 329 IntegerPrefMatchChecker::IntegerPrefMatchChecker(const char* path) | 329 IntegerPrefMatchChecker::IntegerPrefMatchChecker(const char* path) |
| 330 : PrefMatchChecker(path) { | 330 : PrefMatchChecker(path) { |
| 331 } | 331 } |
| 332 | 332 |
| 333 IntegerPrefMatchChecker::~IntegerPrefMatchChecker() { | 333 IntegerPrefMatchChecker::~IntegerPrefMatchChecker() { |
| 334 } | 334 } |
| 335 | 335 |
| 336 bool IntegerPrefMatchChecker::IsExitConditionSatisfied() { | 336 bool IntegerPrefMatchChecker::IsExitConditionSatisfied() { |
| 337 return IntegerPrefMatches(GetPath()); | 337 return IntegerPrefMatches(GetPath()); |
| 338 } | 338 } |
| 339 | 339 |
| 340 // Helper class used in the implementation of AwaitStringPrefMatches. | 340 // Helper class used in the implementation of AwaitStringPrefMatches. |
| 341 class StringPrefMatchChecker : public PrefMatchChecker { | 341 class StringPrefMatchChecker : public PrefMatchChecker { |
| 342 public: | 342 public: |
| 343 explicit StringPrefMatchChecker(const char* path); | 343 explicit StringPrefMatchChecker(const char* path); |
| 344 virtual ~StringPrefMatchChecker(); | 344 virtual ~StringPrefMatchChecker(); |
| 345 | 345 |
| 346 // Implementation of PrefMatchChecker. | 346 // Implementation of PrefMatchChecker. |
| 347 virtual bool IsExitConditionSatisfied() OVERRIDE; | 347 virtual bool IsExitConditionSatisfied() override; |
| 348 }; | 348 }; |
| 349 | 349 |
| 350 StringPrefMatchChecker::StringPrefMatchChecker(const char* path) | 350 StringPrefMatchChecker::StringPrefMatchChecker(const char* path) |
| 351 : PrefMatchChecker(path) { | 351 : PrefMatchChecker(path) { |
| 352 } | 352 } |
| 353 | 353 |
| 354 StringPrefMatchChecker::~StringPrefMatchChecker() { | 354 StringPrefMatchChecker::~StringPrefMatchChecker() { |
| 355 } | 355 } |
| 356 | 356 |
| 357 bool StringPrefMatchChecker::IsExitConditionSatisfied() { | 357 bool StringPrefMatchChecker::IsExitConditionSatisfied() { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 378 return !checker.TimedOut(); | 378 return !checker.TimedOut(); |
| 379 } | 379 } |
| 380 | 380 |
| 381 bool AwaitStringPrefMatches(const char* pref_name) { | 381 bool AwaitStringPrefMatches(const char* pref_name) { |
| 382 StringPrefMatchChecker checker(pref_name); | 382 StringPrefMatchChecker checker(pref_name); |
| 383 checker.Wait(); | 383 checker.Wait(); |
| 384 return !checker.TimedOut(); | 384 return !checker.TimedOut(); |
| 385 } | 385 } |
| 386 | 386 |
| 387 } // namespace preferences_helper | 387 } // namespace preferences_helper |
| OLD | NEW |