OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/signin/signin_error_notifier_ash.h" | 5 #include "chrome/browser/signin/signin_error_notifier_ash.h" |
6 | 6 |
7 #include "ash/test/ash_test_base.h" | 7 #include "ash/test/ash_test_base.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/notifications/notification.h" | 10 #include "chrome/browser/notifications/notification.h" |
11 #include "chrome/browser/notifications/notification_ui_manager.h" | 11 #include "chrome/browser/notifications/notification_ui_manager.h" |
12 #include "chrome/browser/signin/fake_signin_manager.h" | 12 #include "chrome/browser/signin/fake_signin_manager.h" |
13 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 13 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
14 #include "chrome/browser/signin/signin_error_notifier_factory_ash.h" | 14 #include "chrome/browser/signin/signin_error_notifier_factory_ash.h" |
15 #include "chrome/browser/signin/signin_manager_factory.h" | 15 #include "chrome/browser/signin/signin_manager_factory.h" |
16 #include "chrome/browser/ui/ash/test_views_delegate_with_parent.h" | |
17 #include "chrome/test/base/testing_browser_process.h" | 16 #include "chrome/test/base/testing_browser_process.h" |
18 #include "chrome/test/base/testing_profile.h" | 17 #include "chrome/test/base/testing_profile.h" |
19 #include "chrome/test/base/testing_profile_manager.h" | 18 #include "chrome/test/base/testing_profile_manager.h" |
20 #include "components/signin/core/browser/fake_auth_status_provider.h" | 19 #include "components/signin/core/browser/fake_auth_status_provider.h" |
21 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 20 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
22 #include "components/signin/core/browser/signin_error_controller.h" | 21 #include "components/signin/core/browser/signin_error_controller.h" |
23 #include "components/signin/core/browser/signin_manager.h" | 22 #include "components/signin/core/browser/signin_manager.h" |
24 #include "content/public/test/test_browser_thread_bundle.h" | 23 #include "content/public/test/test_browser_thread_bundle.h" |
25 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
26 #include "ui/message_center/notification.h" | 25 #include "ui/message_center/notification.h" |
(...skipping 29 matching lines...) Expand all Loading... |
56 gfx::SCREEN_TYPE_NATIVE; | 55 gfx::SCREEN_TYPE_NATIVE; |
57 } | 56 } |
58 private: | 57 private: |
59 DISALLOW_COPY_AND_ASSIGN(ScreenTypeDelegateDesktop); | 58 DISALLOW_COPY_AND_ASSIGN(ScreenTypeDelegateDesktop); |
60 }; | 59 }; |
61 #endif | 60 #endif |
62 | 61 |
63 class SigninErrorNotifierTest : public AshTestBase { | 62 class SigninErrorNotifierTest : public AshTestBase { |
64 public: | 63 public: |
65 virtual void SetUp() OVERRIDE { | 64 virtual void SetUp() OVERRIDE { |
66 views::ViewsDelegate::views_delegate = &views_delegate_; | |
67 | |
68 // Create a signed-in profile. | 65 // Create a signed-in profile. |
69 TestingProfile::Builder builder; | 66 TestingProfile::Builder builder; |
70 builder.AddTestingFactory(SigninManagerFactory::GetInstance(), | 67 builder.AddTestingFactory(SigninManagerFactory::GetInstance(), |
71 FakeSigninManagerBase::Build); | 68 FakeSigninManagerBase::Build); |
72 profile_ = builder.Build(); | 69 profile_ = builder.Build(); |
73 profile_->set_profile_name(kTestAccountId); | 70 profile_->set_profile_name(kTestAccountId); |
74 | 71 |
75 profile_manager_.reset( | 72 profile_manager_.reset( |
76 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); | 73 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); |
77 ASSERT_TRUE(profile_manager_->SetUp()); | 74 ASSERT_TRUE(profile_manager_->SetUp()); |
(...skipping 26 matching lines...) Expand all Loading... |
104 const Notification* notification = | 101 const Notification* notification = |
105 g_browser_process->notification_ui_manager()->FindById(kNotificationId); | 102 g_browser_process->notification_ui_manager()->FindById(kNotificationId); |
106 ASSERT_FALSE(notification == NULL); | 103 ASSERT_FALSE(notification == NULL); |
107 *message = notification->message(); | 104 *message = notification->message(); |
108 } | 105 } |
109 | 106 |
110 scoped_ptr<TestingProfileManager> profile_manager_; | 107 scoped_ptr<TestingProfileManager> profile_manager_; |
111 scoped_ptr<TestingProfile> profile_; | 108 scoped_ptr<TestingProfile> profile_; |
112 SigninErrorController* error_controller_; | 109 SigninErrorController* error_controller_; |
113 NotificationUIManager* notification_ui_manager_; | 110 NotificationUIManager* notification_ui_manager_; |
114 TestViewsDelegateWithParent views_delegate_; | |
115 }; | 111 }; |
116 | 112 |
117 TEST_F(SigninErrorNotifierTest, NoErrorAuthStatusProviders) { | 113 TEST_F(SigninErrorNotifierTest, NoErrorAuthStatusProviders) { |
118 ASSERT_FALSE(notification_ui_manager_->FindById(kNotificationId)); | 114 ASSERT_FALSE(notification_ui_manager_->FindById(kNotificationId)); |
119 { | 115 { |
120 // Add a provider (removes itself on exiting this scope). | 116 // Add a provider (removes itself on exiting this scope). |
121 FakeAuthStatusProvider provider(error_controller_); | 117 FakeAuthStatusProvider provider(error_controller_); |
122 ASSERT_FALSE(notification_ui_manager_->FindById(kNotificationId)); | 118 ASSERT_FALSE(notification_ui_manager_->FindById(kNotificationId)); |
123 } | 119 } |
124 ASSERT_FALSE(notification_ui_manager_->FindById(kNotificationId)); | 120 ASSERT_FALSE(notification_ui_manager_->FindById(kNotificationId)); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 EXPECT_FALSE(notification->title().empty()); | 222 EXPECT_FALSE(notification->title().empty()); |
227 EXPECT_FALSE(notification->message().empty()); | 223 EXPECT_FALSE(notification->message().empty()); |
228 EXPECT_EQ((size_t)1, notification->buttons().size()); | 224 EXPECT_EQ((size_t)1, notification->buttons().size()); |
229 } | 225 } |
230 } | 226 } |
231 } | 227 } |
232 #endif | 228 #endif |
233 | 229 |
234 } // namespace test | 230 } // namespace test |
235 } // namespace ash | 231 } // namespace ash |
OLD | NEW |