status_change_checker.h revision 5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7
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
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_STATUS_CHANGE_CHECKER_H_
6#define CHROME_BROWSER_SYNC_TEST_INTEGRATION_STATUS_CHANGE_CHECKER_H_
7
8#include <string>
9
10// Interface for a helper class that can be used to check if a desired change in
11// the state of the sync engine has taken place. Used by the desktop sync
12// integration tests.
13//
14// Usage: Tests that want to use this class to wait for an arbitrary sync state
15// must implement a concrete StatusChangeChecker object and pass it to
16// ProfileSyncServiceHarness::AwaitStatusChange().
17class StatusChangeChecker {
18 public:
19  explicit StatusChangeChecker(const std::string& source);
20
21  // Called every time ProfileSyncServiceHarness is notified of a change in the
22  // state of the sync engine. Returns true if the desired change has occurred.
23  virtual bool IsExitConditionSatisfied() = 0;
24
25  std::string source() const { return source_; }
26
27 protected:
28  virtual ~StatusChangeChecker();
29
30 private:
31  // Used for logging / debugging. Can be used to hold the name of the internal
32  // function called by IsExitConditionSatisfied. Logged along with select info
33  // when ProfileSyncServiceHarness observes a change in ProfileSyncService.
34  std::string source_;
35};
36
37#endif  // CHROME_BROWSER_SYNC_TEST_INTEGRATION_STATUS_CHANGE_CHECKER_H_
38