OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "base/memory/scoped_ptr.h" | 5 #include "chrome/browser/sync/sync_startup_tracker.h" |
| 6 |
| 7 #include <memory> |
| 8 |
6 #include "chrome/browser/sync/profile_sync_service_factory.h" | 9 #include "chrome/browser/sync/profile_sync_service_factory.h" |
7 #include "chrome/browser/sync/profile_sync_test_util.h" | 10 #include "chrome/browser/sync/profile_sync_test_util.h" |
8 #include "chrome/browser/sync/sync_startup_tracker.h" | |
9 #include "chrome/test/base/testing_profile.h" | 11 #include "chrome/test/base/testing_profile.h" |
10 #include "content/public/test/test_browser_thread_bundle.h" | 12 #include "content/public/test/test_browser_thread_bundle.h" |
11 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
13 | 15 |
14 using ::testing::_; | 16 using ::testing::_; |
15 using ::testing::AnyNumber; | 17 using ::testing::AnyNumber; |
16 using ::testing::Mock; | 18 using ::testing::Mock; |
17 using ::testing::Return; | 19 using ::testing::Return; |
18 using ::testing::ReturnRef; | 20 using ::testing::ReturnRef; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 .WillRepeatedly(ReturnRef(no_error_)); | 56 .WillRepeatedly(ReturnRef(no_error_)); |
55 EXPECT_CALL(*mock_pss_, IsBackendInitialized()) | 57 EXPECT_CALL(*mock_pss_, IsBackendInitialized()) |
56 .WillRepeatedly(Return(false)); | 58 .WillRepeatedly(Return(false)); |
57 EXPECT_CALL(*mock_pss_, HasUnrecoverableError()) | 59 EXPECT_CALL(*mock_pss_, HasUnrecoverableError()) |
58 .WillRepeatedly(Return(false)); | 60 .WillRepeatedly(Return(false)); |
59 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); | 61 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); |
60 } | 62 } |
61 | 63 |
62 content::TestBrowserThreadBundle thread_bundle_; | 64 content::TestBrowserThreadBundle thread_bundle_; |
63 GoogleServiceAuthError no_error_; | 65 GoogleServiceAuthError no_error_; |
64 scoped_ptr<TestingProfile> profile_; | 66 std::unique_ptr<TestingProfile> profile_; |
65 ProfileSyncServiceMock* mock_pss_; | 67 ProfileSyncServiceMock* mock_pss_; |
66 MockObserver observer_; | 68 MockObserver observer_; |
67 }; | 69 }; |
68 | 70 |
69 TEST_F(SyncStartupTrackerTest, SyncAlreadyInitialized) { | 71 TEST_F(SyncStartupTrackerTest, SyncAlreadyInitialized) { |
70 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(true)); | 72 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(true)); |
71 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); | 73 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); |
72 EXPECT_CALL(observer_, SyncStartupCompleted()); | 74 EXPECT_CALL(observer_, SyncStartupCompleted()); |
73 SyncStartupTracker tracker(profile_.get(), &observer_); | 75 SyncStartupTracker tracker(profile_.get(), &observer_); |
74 } | 76 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false)); | 141 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false)); |
140 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); | 142 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); |
141 GoogleServiceAuthError error( | 143 GoogleServiceAuthError error( |
142 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); | 144 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); |
143 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error)); | 145 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error)); |
144 EXPECT_CALL(observer_, SyncStartupFailed()); | 146 EXPECT_CALL(observer_, SyncStartupFailed()); |
145 tracker.OnStateChanged(); | 147 tracker.OnStateChanged(); |
146 } | 148 } |
147 | 149 |
148 } // namespace | 150 } // namespace |
OLD | NEW |