OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "chrome/browser/browser_thread.h" |
6 #include "chrome/browser/sync/sync_ui_util.h" | 7 #include "chrome/browser/sync/sync_ui_util.h" |
7 #include "chrome/browser/sync/profile_sync_service_mock.h" | 8 #include "chrome/browser/sync/profile_sync_service_mock.h" |
8 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
9 #include "testing/gmock/include/gmock/gmock-actions.h" | 10 #include "testing/gmock/include/gmock/gmock-actions.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
11 | 12 |
12 using ::testing::Return; | 13 using ::testing::Return; |
13 using ::testing::NiceMock; | 14 using ::testing::NiceMock; |
14 TEST(SyncUIUtilTest, ConstructAboutInformationWithUnrecoverableErrorTest) { | 15 TEST(SyncUIUtilTest, ConstructAboutInformationWithUnrecoverableErrorTest) { |
| 16 MessageLoopForUI message_loop; |
| 17 BrowserThread ui_thread(BrowserThread::UI, &message_loop); |
15 NiceMock<ProfileSyncServiceMock> service; | 18 NiceMock<ProfileSyncServiceMock> service; |
16 DictionaryValue strings; | 19 DictionaryValue strings; |
17 | 20 |
18 // Will be released when the dictionary is destroyed | 21 // Will be released when the dictionary is destroyed |
19 string16 str(ASCIIToUTF16("none")); | 22 string16 str(ASCIIToUTF16("none")); |
20 | 23 |
21 browser_sync::SyncBackendHost::Status status = | 24 browser_sync::SyncBackendHost::Status status = |
22 { browser_sync::SyncBackendHost::Status::OFFLINE_UNUSABLE }; | 25 { browser_sync::SyncBackendHost::Status::OFFLINE_UNUSABLE }; |
23 | 26 |
24 EXPECT_CALL(service, HasSyncSetupCompleted()) | 27 EXPECT_CALL(service, HasSyncSetupCompleted()) |
25 .WillOnce(Return(true)); | 28 .WillOnce(Return(true)); |
26 EXPECT_CALL(service, QueryDetailedSyncStatus()) | 29 EXPECT_CALL(service, QueryDetailedSyncStatus()) |
27 .WillOnce(Return(status)); | 30 .WillOnce(Return(status)); |
28 | 31 |
29 EXPECT_CALL(service, unrecoverable_error_detected()) | 32 EXPECT_CALL(service, unrecoverable_error_detected()) |
30 .WillOnce(Return(true)); | 33 .WillOnce(Return(true)); |
31 | 34 |
32 EXPECT_CALL(service, GetLastSyncedTimeString()) | 35 EXPECT_CALL(service, GetLastSyncedTimeString()) |
33 .WillOnce(Return(str)); | 36 .WillOnce(Return(str)); |
34 | 37 |
35 sync_ui_util::ConstructAboutInformation(&service, &strings); | 38 sync_ui_util::ConstructAboutInformation(&service, &strings); |
36 | 39 |
37 EXPECT_TRUE(strings.HasKey("unrecoverable_error_detected")); | 40 EXPECT_TRUE(strings.HasKey("unrecoverable_error_detected")); |
38 } | 41 } |
39 | 42 |
OLD | NEW |