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 <memory> |
| 8 |
7 #include "base/macros.h" | 9 #include "base/macros.h" |
8 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/ptr_util.h" |
9 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
10 #include "chrome/browser/sync/profile_sync_test_util.h" | 12 #include "chrome/browser/sync/profile_sync_test_util.h" |
11 #include "chrome/browser/sync/sync_global_error_factory.h" | 13 #include "chrome/browser/sync/sync_global_error_factory.h" |
12 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 15 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
14 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 16 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
15 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 17 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
16 #include "chrome/test/base/browser_with_test_window_test.h" | 18 #include "chrome/test/base/browser_with_test_window_test.h" |
17 #include "chrome/test/base/testing_profile.h" | 19 #include "chrome/test/base/testing_profile.h" |
18 #include "components/sync_driver/sync_error_controller.h" | 20 #include "components/sync_driver/sync_error_controller.h" |
(...skipping 24 matching lines...) Expand all Loading... |
43 int focus_ui_call_count() const { return focus_ui_call_count_; } | 45 int focus_ui_call_count() const { return focus_ui_call_count_; } |
44 | 46 |
45 private: | 47 private: |
46 // Overridden from LoginUIService::LoginUI: | 48 // Overridden from LoginUIService::LoginUI: |
47 void FocusUI() override { ++focus_ui_call_count_; } | 49 void FocusUI() override { ++focus_ui_call_count_; } |
48 void CloseUI() override {} | 50 void CloseUI() override {} |
49 | 51 |
50 int focus_ui_call_count_; | 52 int focus_ui_call_count_; |
51 }; | 53 }; |
52 | 54 |
53 scoped_ptr<KeyedService> BuildMockLoginUIService( | 55 std::unique_ptr<KeyedService> BuildMockLoginUIService( |
54 content::BrowserContext* profile) { | 56 content::BrowserContext* profile) { |
55 return make_scoped_ptr(new FakeLoginUIService()); | 57 return base::WrapUnique(new FakeLoginUIService()); |
56 } | 58 } |
57 | 59 |
58 // Same as BrowserWithTestWindowTest, but uses MockBrowser to test calls to | 60 // Same as BrowserWithTestWindowTest, but uses MockBrowser to test calls to |
59 // ExecuteCommand method. | 61 // ExecuteCommand method. |
60 class SyncGlobalErrorTest : public BrowserWithTestWindowTest { | 62 class SyncGlobalErrorTest : public BrowserWithTestWindowTest { |
61 public: | 63 public: |
62 SyncGlobalErrorTest() {} | 64 SyncGlobalErrorTest() {} |
63 ~SyncGlobalErrorTest() override {} | 65 ~SyncGlobalErrorTest() override {} |
64 | 66 |
65 void SetUp() override { | 67 void SetUp() override { |
66 profile_ = MakeSignedInTestingProfile(); | 68 profile_ = MakeSignedInTestingProfile(); |
67 | 69 |
68 BrowserWithTestWindowTest::SetUp(); | 70 BrowserWithTestWindowTest::SetUp(); |
69 } | 71 } |
70 | 72 |
71 Profile* profile() { return profile_.get(); } | 73 Profile* profile() { return profile_.get(); } |
72 | 74 |
73 private: | 75 private: |
74 scoped_ptr<TestingProfile> profile_; | 76 std::unique_ptr<TestingProfile> profile_; |
75 | 77 |
76 DISALLOW_COPY_AND_ASSIGN(SyncGlobalErrorTest); | 78 DISALLOW_COPY_AND_ASSIGN(SyncGlobalErrorTest); |
77 }; | 79 }; |
78 | 80 |
79 // Utility function to test that SyncGlobalError behaves correctly for the given | 81 // Utility function to test that SyncGlobalError behaves correctly for the given |
80 // error condition. | 82 // error condition. |
81 void VerifySyncGlobalErrorResult(ProfileSyncServiceMock* service, | 83 void VerifySyncGlobalErrorResult(ProfileSyncServiceMock* service, |
82 FakeLoginUIService* login_ui_service, | 84 FakeLoginUIService* login_ui_service, |
83 Browser* browser, | 85 Browser* browser, |
84 SyncErrorController* error, | 86 SyncErrorController* error, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 .WillRepeatedly(Return(true)); | 166 .WillRepeatedly(Return(true)); |
165 EXPECT_CALL(service, IsPassphraseRequiredForDecryption()) | 167 EXPECT_CALL(service, IsPassphraseRequiredForDecryption()) |
166 .WillRepeatedly(Return(true)); | 168 .WillRepeatedly(Return(true)); |
167 VerifySyncGlobalErrorResult( | 169 VerifySyncGlobalErrorResult( |
168 &service, login_ui_service, browser(), &error, &global_error, | 170 &service, login_ui_service, browser(), &error, &global_error, |
169 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS, | 171 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS, |
170 false /* not signed in */, false /* no error */); | 172 false /* not signed in */, false /* no error */); |
171 | 173 |
172 global_error.Shutdown(); | 174 global_error.Shutdown(); |
173 } | 175 } |
OLD | NEW |