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

Side by Side Diff: trunk/src/chrome/browser/signin/signin_error_notifier_ash_unittest.cc

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

Powered by Google App Engine
This is Rietveld 408576698