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

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

Issue 140883012: Removing "#if 0" style comments (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove empty #if branch Created 6 years, 11 months 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 | « no previous file | no next file » | 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) 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 #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/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
10 #include "chrome/browser/signin/signin_manager.h" 10 #include "chrome/browser/signin/signin_manager.h"
(...skipping 10 matching lines...) Expand all
21 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
22 22
23 using ::testing::NiceMock; 23 using ::testing::NiceMock;
24 using ::testing::Return; 24 using ::testing::Return;
25 using ::testing::ReturnRef; 25 using ::testing::ReturnRef;
26 using ::testing::_; 26 using ::testing::_;
27 using content::BrowserThread; 27 using content::BrowserThread;
28 28
29 namespace { 29 namespace {
30 30
31 #if 0
32 // TODO(altimofeev) See below.
33 class BrowserMock: public Browser {
34 public:
35 explicit BrowserMock(Type type, Profile* profile) : Browser(type, profile) {}
36
37 MOCK_METHOD2(ExecuteCommandWithDisposition,
38 void(int command_id, WindowOpenDisposition));
39 };
40 #endif
41
42 class FakeLoginUIService: public LoginUIService { 31 class FakeLoginUIService: public LoginUIService {
43 public: 32 public:
44 FakeLoginUIService() : LoginUIService(NULL) {} 33 FakeLoginUIService() : LoginUIService(NULL) {}
45 }; 34 };
46 35
47 class FakeLoginUI : public LoginUIService::LoginUI { 36 class FakeLoginUI : public LoginUIService::LoginUI {
48 public: 37 public:
49 FakeLoginUI() : focus_ui_call_count_(0) {} 38 FakeLoginUI() : focus_ui_call_count_(0) {}
50 39
51 virtual ~FakeLoginUI() {} 40 virtual ~FakeLoginUI() {}
(...skipping 15 matching lines...) Expand all
67 return new FakeLoginUIService(); 56 return new FakeLoginUIService();
68 } 57 }
69 58
70 // Same as BrowserWithTestWindowTest, but uses MockBrowser to test calls to 59 // Same as BrowserWithTestWindowTest, but uses MockBrowser to test calls to
71 // ExecuteCommand method. 60 // ExecuteCommand method.
72 class SyncGlobalErrorTest : public BrowserWithTestWindowTest { 61 class SyncGlobalErrorTest : public BrowserWithTestWindowTest {
73 public: 62 public:
74 SyncGlobalErrorTest() {} 63 SyncGlobalErrorTest() {}
75 virtual ~SyncGlobalErrorTest() {} 64 virtual ~SyncGlobalErrorTest() {}
76 65
77 #if 0
78 // TODO(altimofeev): see below.
79 virtual void SetUp() OVERRIDE {
80 testing::Test::SetUp();
81
82 set_profile(CreateProfile());
83 set_browser(new BrowserMock(Browser::TYPE_TABBED, profile()));
84 set_window(new TestBrowserWindow(browser()));
85 browser()->SetWindowForTesting(window());
86 }
87
88 virtual void TearDown() OVERRIDE {
89 testing::Test::TearDown();
90 }
91 #endif
92
93 private: 66 private:
94 DISALLOW_COPY_AND_ASSIGN(SyncGlobalErrorTest); 67 DISALLOW_COPY_AND_ASSIGN(SyncGlobalErrorTest);
95 }; 68 };
96 69
97 // Utility function to test that SyncGlobalError behaves correct for the given 70 // Utility function to test that SyncGlobalError behaves correct for the given
98 // error condition. 71 // error condition.
99 void VerifySyncGlobalErrorResult(NiceMock<ProfileSyncServiceMock>* service, 72 void VerifySyncGlobalErrorResult(NiceMock<ProfileSyncServiceMock>* service,
100 FakeLoginUIService* login_ui_service, 73 FakeLoginUIService* login_ui_service,
101 Browser* browser, 74 Browser* browser,
102 SyncGlobalError* error, 75 SyncGlobalError* error,
(...skipping 15 matching lines...) Expand all
118 // If there is an error then labels should not be empty. 91 // If there is an error then labels should not be empty.
119 EXPECT_NE(error->MenuItemCommandID(), 0); 92 EXPECT_NE(error->MenuItemCommandID(), 0);
120 EXPECT_NE(error->MenuItemLabel().empty(), is_error); 93 EXPECT_NE(error->MenuItemLabel().empty(), is_error);
121 EXPECT_NE(error->GetBubbleViewAcceptButtonLabel().empty(), is_error); 94 EXPECT_NE(error->GetBubbleViewAcceptButtonLabel().empty(), is_error);
122 95
123 // We never have a cancel button. 96 // We never have a cancel button.
124 EXPECT_TRUE(error->GetBubbleViewCancelButtonLabel().empty()); 97 EXPECT_TRUE(error->GetBubbleViewCancelButtonLabel().empty());
125 // We always return a hardcoded title. 98 // We always return a hardcoded title.
126 EXPECT_FALSE(error->GetBubbleViewTitle().empty()); 99 EXPECT_FALSE(error->GetBubbleViewTitle().empty());
127 100
128 #if defined(OS_CHROMEOS) 101 // TODO(altimofeev): Implement this for ChromeOS in a way that doesn't involve
129 // TODO(altimofeev): Implement this in a way that doesn't involve subclassing 102 // subclassing Browser or using GMock on browser/ui types
130 // Browser or using GMock on browser/ui types which is 103 // which is banned. Consider observing
131 // banned. Consider observing NOTIFICATION_APP_TERMINATING 104 // NOTIFICATION_APP_TERMINATING instead.
132 // instead.
133 // http://crbug.com/134675 105 // http://crbug.com/134675
134 #else 106 #if !defined(OS_CHROMEOS)
135 #if defined(OS_CHROMEOS)
136 if (error_state != GoogleServiceAuthError::NONE) {
137 // In CrOS sign-in/sign-out is made to fix the error.
138 EXPECT_CALL(*static_cast<BrowserMock*>(browser),
139 ExecuteCommandWithDisposition(IDC_EXIT, _));
140 error->ExecuteMenuItem(browser);
141 }
142 #else
143 // Test message handler. 107 // Test message handler.
144 if (is_error) { 108 if (is_error) {
145 FakeLoginUI* login_ui = static_cast<FakeLoginUI*>( 109 FakeLoginUI* login_ui = static_cast<FakeLoginUI*>(
146 login_ui_service->current_login_ui()); 110 login_ui_service->current_login_ui());
147 error->ExecuteMenuItem(browser); 111 error->ExecuteMenuItem(browser);
148 ASSERT_GT(login_ui->focus_ui_call_count(), 0); 112 ASSERT_GT(login_ui->focus_ui_call_count(), 0);
149 error->BubbleViewAcceptButtonPressed(browser); 113 error->BubbleViewAcceptButtonPressed(browser);
150 error->BubbleViewDidClose(browser); 114 error->BubbleViewDidClose(browser);
151 } 115 }
152 #endif 116 #endif
153 #endif
154 } 117 }
155 118
156 } // namespace 119 } // namespace
157 120
158 // Test that SyncGlobalError shows an error if a passphrase is required. 121 // Test that SyncGlobalError shows an error if a passphrase is required.
159 TEST_F(SyncGlobalErrorTest, PassphraseGlobalError) { 122 TEST_F(SyncGlobalErrorTest, PassphraseGlobalError) {
160 scoped_ptr<Profile> profile( 123 scoped_ptr<Profile> profile(
161 ProfileSyncServiceMock::MakeSignedInTestingProfile()); 124 ProfileSyncServiceMock::MakeSignedInTestingProfile());
162 NiceMock<ProfileSyncServiceMock> service(profile.get()); 125 NiceMock<ProfileSyncServiceMock> service(profile.get());
163 SigninManagerBase* signin = 126 SigninManagerBase* signin =
(...skipping 10 matching lines...) Expand all
174 .WillRepeatedly(Return(false)); 137 .WillRepeatedly(Return(false));
175 138
176 EXPECT_CALL(service, IsPassphraseRequired()) 139 EXPECT_CALL(service, IsPassphraseRequired())
177 .WillRepeatedly(Return(true)); 140 .WillRepeatedly(Return(true));
178 EXPECT_CALL(service, IsPassphraseRequiredForDecryption()) 141 EXPECT_CALL(service, IsPassphraseRequiredForDecryption())
179 .WillRepeatedly(Return(true)); 142 .WillRepeatedly(Return(true));
180 VerifySyncGlobalErrorResult( 143 VerifySyncGlobalErrorResult(
181 &service, login_ui_service, browser(), &error, 144 &service, login_ui_service, browser(), &error,
182 GoogleServiceAuthError::NONE, true, true); 145 GoogleServiceAuthError::NONE, true, true);
183 } 146 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698