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.
5 #ifndef CHROME_BROWSER_SYNC_PROFILE_SYNC_TEST_UTIL_H_
6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_TEST_UTIL_H_
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"
24 ACTION_P(Notify
, type
) {
25 content::NotificationService::current()->Notify(
27 content::NotificationService::AllSources(),
28 content::NotificationService::NoDetails());
31 ACTION(QuitUIMessageLoop
) {
32 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI
));
33 base::MessageLoop::current()->Quit();
36 class ProfileSyncServiceObserverMock
: public ProfileSyncServiceObserver
{
38 ProfileSyncServiceObserverMock();
39 virtual ~ProfileSyncServiceObserverMock();
41 MOCK_METHOD0(OnStateChanged
, void());
44 class ThreadNotifier
: // NOLINT
45 public base::RefCountedThreadSafe
<ThreadNotifier
> {
47 explicit ThreadNotifier(base::Thread
* notify_thread
);
49 void Notify(int type
, const content::NotificationDetails
& details
);
52 const content::NotificationSource
& source
,
53 const content::NotificationDetails
& details
);
56 friend class base::RefCountedThreadSafe
<ThreadNotifier
>;
57 virtual ~ThreadNotifier();
59 void NotifyTask(int type
,
60 const content::NotificationSource
& source
,
61 const content::NotificationDetails
& details
);
63 base::WaitableEvent done_event_
;
64 base::Thread
* notify_thread_
;
67 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_TEST_UTIL_H_