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" |
11 #include "chrome/browser/sync/profile_sync_service_mock.h" | 11 #include "chrome/browser/sync/profile_sync_service_mock.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/test/base/browser_with_test_window_test.h" | 13 #include "chrome/test/base/browser_with_test_window_test.h" |
14 #include "chrome/test/base/testing_profile.h" | 14 #include "chrome/test/base/testing_profile.h" |
15 #include "content/test/test_browser_thread.h" | 15 #include "content/test/test_browser_thread.h" |
16 #include "testing/gmock/include/gmock/gmock-actions.h" | 16 #include "testing/gmock/include/gmock/gmock-actions.h" |
17 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 | 19 |
| 20 using ::testing::NiceMock; |
20 using ::testing::Return; | 21 using ::testing::Return; |
21 using ::testing::ReturnRef; | 22 using ::testing::ReturnRef; |
22 using ::testing::NiceMock; | 23 using ::testing::_; |
23 using content::BrowserThread; | 24 using content::BrowserThread; |
24 | 25 |
25 namespace { | 26 namespace { |
26 | 27 |
27 class BrowserMock: public Browser { | 28 class BrowserMock: public Browser { |
28 public: | 29 public: |
29 explicit BrowserMock(Type type, Profile* profile) : Browser(type, profile) {} | 30 explicit BrowserMock(Type type, Profile* profile) : Browser(type, profile) {} |
30 | 31 |
31 MOCK_METHOD1(ExecuteCommand, void(int command_id)); | 32 MOCK_METHOD2(ExecuteCommandWithDisposition, |
| 33 void(int command_id, WindowOpenDisposition)); |
32 }; | 34 }; |
33 | 35 |
34 // Same as BrowserWithTestWindowTest, but uses MockBrowser to test calls to | 36 // Same as BrowserWithTestWindowTest, but uses MockBrowser to test calls to |
35 // ExecuteCommand method. | 37 // ExecuteCommand method. |
36 class SyncGlobalErrorTest : public BrowserWithTestWindowTest { | 38 class SyncGlobalErrorTest : public BrowserWithTestWindowTest { |
37 public: | 39 public: |
38 SyncGlobalErrorTest() {} | 40 SyncGlobalErrorTest() {} |
39 virtual ~SyncGlobalErrorTest() {} | 41 virtual ~SyncGlobalErrorTest() {} |
40 | 42 |
41 virtual void SetUp() OVERRIDE { | 43 virtual void SetUp() OVERRIDE { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 EXPECT_NE(error->GetBubbleViewAcceptButtonLabel().empty(), is_error); | 82 EXPECT_NE(error->GetBubbleViewAcceptButtonLabel().empty(), is_error); |
81 | 83 |
82 // We never have a cancel button. | 84 // We never have a cancel button. |
83 EXPECT_TRUE(error->GetBubbleViewCancelButtonLabel().empty()); | 85 EXPECT_TRUE(error->GetBubbleViewCancelButtonLabel().empty()); |
84 // We always return a hardcoded title. | 86 // We always return a hardcoded title. |
85 EXPECT_FALSE(error->GetBubbleViewTitle().empty()); | 87 EXPECT_FALSE(error->GetBubbleViewTitle().empty()); |
86 | 88 |
87 #if defined(OS_CHROMEOS) | 89 #if defined(OS_CHROMEOS) |
88 if (error_state != GoogleServiceAuthError::NONE) { | 90 if (error_state != GoogleServiceAuthError::NONE) { |
89 // In CrOS sign-in/sign-out is made to fix the error. | 91 // In CrOS sign-in/sign-out is made to fix the error. |
90 EXPECT_CALL(*static_cast<BrowserMock*>(browser), ExecuteCommand(IDC_EXIT)); | 92 EXPECT_CALL(*static_cast<BrowserMock*>(browser), |
| 93 ExecuteCommandWithDisposition(IDC_EXIT, _)); |
91 error->ExecuteMenuItem(browser); | 94 error->ExecuteMenuItem(browser); |
92 } | 95 } |
93 #else | 96 #else |
94 // Test message handler. | 97 // Test message handler. |
95 if (is_error) { | 98 if (is_error) { |
96 EXPECT_CALL(*service, ShowErrorUI()); | 99 EXPECT_CALL(*service, ShowErrorUI()); |
97 error->ExecuteMenuItem(browser); | 100 error->ExecuteMenuItem(browser); |
98 EXPECT_CALL(*service, ShowErrorUI()); | 101 EXPECT_CALL(*service, ShowErrorUI()); |
99 error->BubbleViewAcceptButtonPressed(browser); | 102 error->BubbleViewAcceptButtonPressed(browser); |
100 error->BubbleViewDidClose(browser); | 103 error->BubbleViewDidClose(browser); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 { GoogleServiceAuthError::HOSTED_NOT_ALLOWED, true }, | 152 { GoogleServiceAuthError::HOSTED_NOT_ALLOWED, true }, |
150 }; | 153 }; |
151 | 154 |
152 for (size_t i = 0; i < sizeof(table)/sizeof(*table); ++i) { | 155 for (size_t i = 0; i < sizeof(table)/sizeof(*table); ++i) { |
153 VerifySyncGlobalErrorResult(&service, browser(), &error, | 156 VerifySyncGlobalErrorResult(&service, browser(), &error, |
154 table[i].error_state, true, table[i].is_error); | 157 table[i].error_state, true, table[i].is_error); |
155 VerifySyncGlobalErrorResult(&service, browser(), &error, | 158 VerifySyncGlobalErrorResult(&service, browser(), &error, |
156 table[i].error_state, false, false); | 159 table[i].error_state, false, false); |
157 } | 160 } |
158 } | 161 } |
OLD | NEW |