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 #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/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 Loading... |
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. |
31 class BrowserMock: public Browser { | 33 class BrowserMock: public Browser { |
32 public: | 34 public: |
33 explicit BrowserMock(Type type, Profile* profile) : Browser(type, profile) {} | 35 explicit BrowserMock(Type type, Profile* profile) : Browser(type, profile) {} |
34 | 36 |
35 MOCK_METHOD2(ExecuteCommandWithDisposition, | 37 MOCK_METHOD2(ExecuteCommandWithDisposition, |
36 void(int command_id, WindowOpenDisposition)); | 38 void(int command_id, WindowOpenDisposition)); |
37 }; | 39 }; |
| 40 #endif |
38 | 41 |
39 class LoginUIServiceMock: public LoginUIService { | 42 class LoginUIServiceMock: public LoginUIService { |
40 public: | 43 public: |
41 explicit LoginUIServiceMock() : LoginUIService() {} | 44 explicit LoginUIServiceMock() : LoginUIService() {} |
42 MOCK_METHOD1(ShowLoginUI, void(Browser*)); | 45 MOCK_METHOD1(ShowLoginUI, void(Browser*)); |
43 }; | 46 }; |
44 | 47 |
45 ProfileKeyedService* BuildMockLoginUIService(Profile* profile) { | 48 ProfileKeyedService* BuildMockLoginUIService(Profile* profile) { |
46 return new LoginUIServiceMock(); | 49 return new LoginUIServiceMock(); |
47 } | 50 } |
48 | 51 |
49 // Same as BrowserWithTestWindowTest, but uses MockBrowser to test calls to | 52 // Same as BrowserWithTestWindowTest, but uses MockBrowser to test calls to |
50 // ExecuteCommand method. | 53 // ExecuteCommand method. |
51 class SyncGlobalErrorTest : public BrowserWithTestWindowTest { | 54 class SyncGlobalErrorTest : public BrowserWithTestWindowTest { |
52 public: | 55 public: |
53 SyncGlobalErrorTest() {} | 56 SyncGlobalErrorTest() {} |
54 virtual ~SyncGlobalErrorTest() {} | 57 virtual ~SyncGlobalErrorTest() {} |
55 | 58 |
| 59 #if 0 |
| 60 // TODO(altimofeev): see below. |
56 virtual void SetUp() OVERRIDE { | 61 virtual void SetUp() OVERRIDE { |
57 testing::Test::SetUp(); | 62 testing::Test::SetUp(); |
58 | 63 |
59 set_profile(CreateProfile()); | 64 set_profile(CreateProfile()); |
60 set_browser(new BrowserMock(Browser::TYPE_TABBED, profile())); | 65 set_browser(new BrowserMock(Browser::TYPE_TABBED, profile())); |
61 set_window(new TestBrowserWindow(browser())); | 66 set_window(new TestBrowserWindow(browser())); |
62 browser()->SetWindowForTesting(window()); | 67 browser()->SetWindowForTesting(window()); |
63 } | 68 } |
64 | 69 |
65 virtual void TearDown() OVERRIDE { | 70 virtual void TearDown() OVERRIDE { |
66 testing::Test::TearDown(); | 71 testing::Test::TearDown(); |
67 } | 72 } |
| 73 #endif |
68 | 74 |
69 private: | 75 private: |
70 DISALLOW_COPY_AND_ASSIGN(SyncGlobalErrorTest); | 76 DISALLOW_COPY_AND_ASSIGN(SyncGlobalErrorTest); |
71 }; | 77 }; |
72 | 78 |
73 // Utility function to test that SyncGlobalError behaves correct for the given | 79 // Utility function to test that SyncGlobalError behaves correct for the given |
74 // error condition. | 80 // error condition. |
75 void VerifySyncGlobalErrorResult(NiceMock<ProfileSyncServiceMock>* service, | 81 void VerifySyncGlobalErrorResult(NiceMock<ProfileSyncServiceMock>* service, |
76 LoginUIServiceMock* login_ui_service, | 82 LoginUIServiceMock* login_ui_service, |
77 Browser* browser, | 83 Browser* browser, |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 { GoogleServiceAuthError::HOSTED_NOT_ALLOWED, true }, | 197 { GoogleServiceAuthError::HOSTED_NOT_ALLOWED, true }, |
192 }; | 198 }; |
193 | 199 |
194 for (size_t i = 0; i < sizeof(table)/sizeof(*table); ++i) { | 200 for (size_t i = 0; i < sizeof(table)/sizeof(*table); ++i) { |
195 VerifySyncGlobalErrorResult(&service, login_ui_service, browser(), &error, | 201 VerifySyncGlobalErrorResult(&service, login_ui_service, browser(), &error, |
196 table[i].error_state, true, table[i].is_error); | 202 table[i].error_state, true, table[i].is_error); |
197 VerifySyncGlobalErrorResult(&service, login_ui_service, browser(), &error, | 203 VerifySyncGlobalErrorResult(&service, login_ui_service, browser(), &error, |
198 table[i].error_state, false, false); | 204 table[i].error_state, false, false); |
199 } | 205 } |
200 } | 206 } |
OLD | NEW |