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 "components/sync_driver/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_CURRENTLY_ON(content::BrowserThread::UI
);
33 base::MessageLoop::current()->Quit();
36 class SyncServiceObserverMock
: public sync_driver::SyncServiceObserver
{
38 SyncServiceObserverMock();
39 virtual ~SyncServiceObserverMock();
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_