| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_PROFILE_SYNC_TEST_UTIL_H_ | 5 #ifndef CHROME_BROWSER_SYNC_PROFILE_SYNC_TEST_UTIL_H_ |
| 6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_TEST_UTIL_H_ | 6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_TEST_UTIL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "base/synchronization/waitable_event.h" | 13 #include "base/synchronization/waitable_event.h" |
| 14 #include "components/browser_sync/browser/profile_sync_service_mock.h" | 14 #include "components/browser_sync/browser/profile_sync_service_mock.h" |
| 15 #include "components/sync_driver/sync_service_observer.h" | |
| 16 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
| 17 #include "content/public/browser/notification_service.h" | 16 #include "content/public/browser/notification_service.h" |
| 18 #include "content/public/browser/notification_source.h" | 17 #include "content/public/browser/notification_source.h" |
| 19 #include "content/public/browser/notification_types.h" | 18 #include "content/public/browser/notification_types.h" |
| 20 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
| 21 | 20 |
| 22 namespace base { | |
| 23 class Thread; | |
| 24 class Time; | |
| 25 class TimeDelta; | |
| 26 } | |
| 27 | |
| 28 namespace content { | 21 namespace content { |
| 29 class BrowserContext; | 22 class BrowserContext; |
| 30 } | 23 } |
| 31 | 24 |
| 32 namespace sync_driver { | 25 namespace sync_driver { |
| 33 class SyncClient; | 26 class SyncClient; |
| 34 } | 27 } |
| 35 | 28 |
| 36 class KeyedService; | 29 class KeyedService; |
| 37 class Profile; | 30 class Profile; |
| 38 class ProfileSyncServiceMock; | 31 class ProfileSyncServiceMock; |
| 39 class TestingProfile; | 32 class TestingProfile; |
| 40 | 33 |
| 41 // An empty syncer::NetworkTimeUpdateCallback. Used in various tests to | |
| 42 // instantiate ProfileSyncService. | |
| 43 void EmptyNetworkTimeUpdate(const base::Time&, | |
| 44 const base::TimeDelta&, | |
| 45 const base::TimeDelta&); | |
| 46 | |
| 47 ACTION_P(Notify, type) { | 34 ACTION_P(Notify, type) { |
| 48 content::NotificationService::current()->Notify( | 35 content::NotificationService::current()->Notify( |
| 49 type, | 36 type, |
| 50 content::NotificationService::AllSources(), | 37 content::NotificationService::AllSources(), |
| 51 content::NotificationService::NoDetails()); | 38 content::NotificationService::NoDetails()); |
| 52 } | 39 } |
| 53 | 40 |
| 54 ACTION(QuitUIMessageLoop) { | 41 ACTION(QuitUIMessageLoop) { |
| 55 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 42 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 56 base::MessageLoop::current()->QuitWhenIdle(); | 43 base::MessageLoop::current()->QuitWhenIdle(); |
| 57 } | 44 } |
| 58 | 45 |
| 59 class SyncServiceObserverMock : public sync_driver::SyncServiceObserver { | |
| 60 public: | |
| 61 SyncServiceObserverMock(); | |
| 62 virtual ~SyncServiceObserverMock(); | |
| 63 | |
| 64 MOCK_METHOD0(OnStateChanged, void()); | |
| 65 }; | |
| 66 | |
| 67 class ThreadNotifier : // NOLINT | 46 class ThreadNotifier : // NOLINT |
| 68 public base::RefCountedThreadSafe<ThreadNotifier> { | 47 public base::RefCountedThreadSafe<ThreadNotifier> { |
| 69 public: | 48 public: |
| 70 explicit ThreadNotifier(base::Thread* notify_thread); | 49 explicit ThreadNotifier(base::Thread* notify_thread); |
| 71 | 50 |
| 72 void Notify(int type, const content::NotificationDetails& details); | 51 void Notify(int type, const content::NotificationDetails& details); |
| 73 | 52 |
| 74 void Notify(int type, | 53 void Notify(int type, |
| 75 const content::NotificationSource& source, | 54 const content::NotificationSource& source, |
| 76 const content::NotificationDetails& details); | 55 const content::NotificationDetails& details); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 97 // A utility used by sync tests to create a TestingProfile with a Google | 76 // A utility used by sync tests to create a TestingProfile with a Google |
| 98 // Services username stored in a (Testing)PrefService. | 77 // Services username stored in a (Testing)PrefService. |
| 99 scoped_ptr<TestingProfile> MakeSignedInTestingProfile(); | 78 scoped_ptr<TestingProfile> MakeSignedInTestingProfile(); |
| 100 | 79 |
| 101 // Helper routine to be used in conjunction with | 80 // Helper routine to be used in conjunction with |
| 102 // BrowserContextKeyedServiceFactory::SetTestingFactory(). | 81 // BrowserContextKeyedServiceFactory::SetTestingFactory(). |
| 103 scoped_ptr<KeyedService> BuildMockProfileSyncService( | 82 scoped_ptr<KeyedService> BuildMockProfileSyncService( |
| 104 content::BrowserContext* context); | 83 content::BrowserContext* context); |
| 105 | 84 |
| 106 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_TEST_UTIL_H_ | 85 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_TEST_UTIL_H_ |
| OLD | NEW |