Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: chrome/browser/sync/test/integration/status_change_checker.h

Issue 299843007: sync: Refactor StatusChangeChecker hierarchy (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fixes Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_STATUS_CHANGE_CHECKER_H_ 5 #ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_STATUS_CHANGE_CHECKER_H_
6 #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_STATUS_CHANGE_CHECKER_H_ 6 #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_STATUS_CHANGE_CHECKER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/time/time.h"
11
10 class ProfileSyncServiceHarness; 12 class ProfileSyncServiceHarness;
11 13
12 // Interface for a helper class that can be used to check if a desired change in 14 // Interface for a helper class that can pump the message loop while waiting
13 // the state of the sync engine has taken place. Used by the desktop sync 15 // for a certain state transition to take place.
14 // integration tests.
15 // 16 //
16 // Usage: Tests that want to use this class to wait for an arbitrary sync state 17 // This is a template that should be filled in by child classes so they can
17 // must implement a concrete StatusChangeChecker object and pass it to 18 // observe specific kinds of changes and await specific conditions.
18 // ProfileSyncServiceHarness::AwaitStatusChange(). 19 //
20 // The instances of this class are intended to be single-use. It doesn't make
21 // sense to call StartBlockingWait() more than once.
19 class StatusChangeChecker { 22 class StatusChangeChecker {
20 public: 23 public:
21 explicit StatusChangeChecker(); 24 explicit StatusChangeChecker();
22 25
23 // Called every time ProfileSyncServiceHarness is notified of a change in the
24 // state of the sync engine. Returns true if the desired change has occurred.
25 virtual bool IsExitConditionSatisfied() = 0;
26
27 // Returns a string representing this current StatusChangeChecker, and 26 // Returns a string representing this current StatusChangeChecker, and
28 // possibly some small part of its state. For example: "AwaitPassphraseError" 27 // possibly some small part of its state. For example: "AwaitPassphraseError"
29 // or "AwaitMigrationDone(BOOKMARKS)". 28 // or "AwaitMigrationDone(BOOKMARKS)".
30 virtual std::string GetDebugMessage() const = 0; 29 virtual std::string GetDebugMessage() const = 0;
31 30
31 // Returns true if the blocking wait was exited because of a timeout.
32 bool TimedOut() const;
33
34 virtual bool IsExitConditionSatisfied() = 0;
35
32 protected: 36 protected:
33 virtual ~StatusChangeChecker(); 37 virtual ~StatusChangeChecker();
38
39 // Timeout length when blocking.
40 virtual base::TimeDelta GetTimeoutDuration();
41
42 // Helper function to start running the nested message loop.
43 //
44 // Will exit if IsExitConditionSatisfied() returns true when called from
45 // CheckExitCondition(), if a timeout occurs, or if StopWaiting() is called.
46 //
47 // The timeout length is specified with GetTimeoutDuration().
48 void StartBlockingWait();
49
50 // Stop the nested running of the message loop started in StartBlockingWait().
51 void StopWaiting();
52
53 // Checks IsExitConditionSatisfied() and calls StopWaiting() if it returns
54 // true.
55 void CheckExitCondition();
56
57 // Called when the blocking wait timeout is exceeded.
58 void OnTimeout();
59
60 bool timed_out_;
61 bool wait_started_;
34 }; 62 };
35 63
36 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_STATUS_CHANGE_CHECKER_H_ 64 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_STATUS_CHANGE_CHECKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698