Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: chrome/browser/sync/sync_global_error_unittest.cc

Issue 8383036: Adding parameter to GetStatusLabels to indicate if links are acceptable. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Further test fixes. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/sync/profile_sync_service_mock.h ('k') | chrome/browser/sync/sync_ui_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/sync/sync_global_error.h" 5 #include "chrome/browser/sync/sync_global_error.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/sync/profile_sync_service_mock.h" 9 #include "chrome/browser/sync/profile_sync_service_mock.h"
10 #include "content/test/test_browser_thread.h" 10 #include "content/test/test_browser_thread.h"
11 #include "testing/gmock/include/gmock/gmock-actions.h" 11 #include "testing/gmock/include/gmock/gmock-actions.h"
12 #include "testing/gmock/include/gmock/gmock.h" 12 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 using ::testing::Return; 15 using ::testing::Return;
16 using ::testing::ReturnRef;
16 using ::testing::NiceMock; 17 using ::testing::NiceMock;
17 using content::BrowserThread; 18 using content::BrowserThread;
18 19
19 namespace { 20 namespace {
20 21
21 // Utility function to test that SyncGlobalError behaves correct for the given 22 // Utility function to test that SyncGlobalError behaves correct for the given
22 // error condition. 23 // error condition.
23 void VerifySyncGlobalErrorResult(NiceMock<ProfileSyncServiceMock>* service, 24 void VerifySyncGlobalErrorResult(NiceMock<ProfileSyncServiceMock>* service,
24 SyncGlobalError* error, 25 SyncGlobalError* error,
25 GoogleServiceAuthError::State error_state, 26 GoogleServiceAuthError::State error_state,
26 bool is_signed_in, 27 bool is_signed_in,
27 bool is_error) { 28 bool is_error) {
28 GoogleServiceAuthError auth_error(error_state);
29 service->UpdateAuthErrorState(auth_error);
30
31 EXPECT_CALL(*service, HasSyncSetupCompleted()) 29 EXPECT_CALL(*service, HasSyncSetupCompleted())
32 .WillRepeatedly(Return(is_signed_in)); 30 .WillRepeatedly(Return(is_signed_in));
33 if (error_state == GoogleServiceAuthError::SERVICE_UNAVAILABLE) { 31 if (error_state == GoogleServiceAuthError::SERVICE_UNAVAILABLE) {
34 EXPECT_CALL(*service, GetAuthenticatedUsername()) 32 EXPECT_CALL(*service, GetAuthenticatedUsername())
35 .WillRepeatedly(Return(UTF8ToUTF16(""))); 33 .WillRepeatedly(Return(UTF8ToUTF16("")));
36 } else { 34 } else {
37 EXPECT_CALL(*service, GetAuthenticatedUsername()) 35 EXPECT_CALL(*service, GetAuthenticatedUsername())
38 .WillRepeatedly(Return(UTF8ToUTF16("foo"))); 36 .WillRepeatedly(Return(UTF8ToUTF16("foo")));
39 } 37 }
40 38
39 GoogleServiceAuthError auth_error(error_state);
40 EXPECT_CALL(*service, GetAuthError()).WillRepeatedly(ReturnRef(auth_error));
41
41 error->OnStateChanged(); 42 error->OnStateChanged();
42 43
43 // If there is an error then a wrench button badge, menu item, and bubble view 44 // If there is an error then a wrench button badge, menu item, and bubble view
44 // should be shown. 45 // should be shown.
45 EXPECT_EQ(error->HasBadge(), is_error); 46 EXPECT_EQ(error->HasBadge(), is_error);
46 EXPECT_EQ(error->HasMenuItem() || error->HasCustomizedSyncMenuItem(), 47 EXPECT_EQ(error->HasMenuItem() || error->HasCustomizedSyncMenuItem(),
47 is_error); 48 is_error);
48 EXPECT_EQ(error->HasBubbleView(), is_error); 49 EXPECT_EQ(error->HasBubbleView(), is_error);
49 50
50 // If there is an error then labels should not be empty. 51 // If there is an error then labels should not be empty.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 { GoogleServiceAuthError::HOSTED_NOT_ALLOWED, true }, 115 { GoogleServiceAuthError::HOSTED_NOT_ALLOWED, true },
115 }; 116 };
116 117
117 for (size_t i = 0; i < sizeof(table)/sizeof(*table); ++i) { 118 for (size_t i = 0; i < sizeof(table)/sizeof(*table); ++i) {
118 VerifySyncGlobalErrorResult( 119 VerifySyncGlobalErrorResult(
119 &service, &error, table[i].error_state, true, table[i].is_error); 120 &service, &error, table[i].error_state, true, table[i].is_error);
120 VerifySyncGlobalErrorResult( 121 VerifySyncGlobalErrorResult(
121 &service, &error, table[i].error_state, false, false); 122 &service, &error, table[i].error_state, false, false);
122 } 123 }
123 } 124 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service_mock.h ('k') | chrome/browser/sync/sync_ui_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698