- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / sync / profile_sync_test_util.h
1 // Copyright (c) 2012 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_PROFILE_SYNC_TEST_UTIL_H_
6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_TEST_UTIL_H_
7
8 #include <string>
9
10 #include "base/memory/ref_counted.h"
11 #include "base/message_loop/message_loop.h"
12 #include "base/synchronization/waitable_event.h"
13 #include "chrome/browser/sync/profile_sync_service_observer.h"
14 #include "content/public/browser/browser_thread.h"
15 #include "content/public/browser/notification_service.h"
16 #include "content/public/browser/notification_source.h"
17 #include "content/public/browser/notification_types.h"
18 #include "testing/gmock/include/gmock/gmock.h"
19
20 namespace base {
21 class Thread;
22 }
23
24 ACTION_P(Notify, type) {
25   content::NotificationService::current()->Notify(
26       type,
27       content::NotificationService::AllSources(),
28       content::NotificationService::NoDetails());
29 }
30
31 ACTION(QuitUIMessageLoop) {
32   DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
33   base::MessageLoop::current()->Quit();
34 }
35
36 class ProfileSyncServiceObserverMock : public ProfileSyncServiceObserver {
37  public:
38   ProfileSyncServiceObserverMock();
39   virtual ~ProfileSyncServiceObserverMock();
40
41   MOCK_METHOD0(OnStateChanged, void());
42 };
43
44 class ThreadNotifier :  // NOLINT
45     public base::RefCountedThreadSafe<ThreadNotifier> {
46  public:
47   explicit ThreadNotifier(base::Thread* notify_thread);
48
49   void Notify(int type, const content::NotificationDetails& details);
50
51   void Notify(int type,
52               const content::NotificationSource& source,
53               const content::NotificationDetails& details);
54
55  private:
56   friend class base::RefCountedThreadSafe<ThreadNotifier>;
57   virtual ~ThreadNotifier();
58
59   void NotifyTask(int type,
60                   const content::NotificationSource& source,
61                   const content::NotificationDetails& details);
62
63   base::WaitableEvent done_event_;
64   base::Thread* notify_thread_;
65 };
66
67 #endif  // CHROME_BROWSER_SYNC_PROFILE_SYNC_TEST_UTIL_H_