OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_global_error.h" | 5 #include "chrome/browser/signin/signin_global_error.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/prefs/pref_service.h" |
8 #include "chrome/browser/signin/fake_auth_status_provider.h" | 9 #include "chrome/browser/signin/fake_auth_status_provider.h" |
9 #include "chrome/browser/signin/fake_signin_manager.h" | 10 #include "chrome/browser/signin/fake_signin_manager.h" |
10 #include "chrome/browser/signin/signin_manager.h" | 11 #include "chrome/browser/signin/signin_manager.h" |
11 #include "chrome/browser/signin/signin_manager_factory.h" | 12 #include "chrome/browser/signin/signin_manager_factory.h" |
12 #include "chrome/browser/signin/token_service_factory.h" | 13 #include "chrome/browser/signin/token_service_factory.h" |
13 #include "chrome/browser/ui/global_error/global_error_service.h" | 14 #include "chrome/browser/ui/global_error/global_error_service.h" |
14 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 15 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
| 16 #include "chrome/common/pref_names.h" |
15 #include "chrome/test/base/testing_profile.h" | 17 #include "chrome/test/base/testing_profile.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
17 | 19 |
18 class SigninGlobalErrorTest : public testing::Test { | 20 class SigninGlobalErrorTest : public testing::Test { |
19 public: | 21 public: |
20 virtual void SetUp() OVERRIDE { | 22 virtual void SetUp() OVERRIDE { |
21 // Create a signed-in profile. | 23 // Create a signed-in profile. |
22 profile_.reset(new TestingProfile()); | 24 profile_.reset(new TestingProfile()); |
23 | 25 |
24 SigninManagerBase* manager = static_cast<SigninManagerBase*>( | 26 SigninManagerBase* manager = static_cast<SigninManagerBase*>( |
25 SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse( | 27 SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse( |
26 profile_.get(), FakeSigninManagerBase::Build)); | 28 profile_.get(), FakeSigninManagerBase::Build)); |
27 manager->SetAuthenticatedUsername("testuser@test.com"); | 29 profile_->GetPrefs()->SetString( |
| 30 prefs::kGoogleServicesUsername, "testuser@test.com"); |
| 31 manager->Initialize(profile_.get()); |
28 global_error_ = manager->signin_global_error(); | 32 global_error_ = manager->signin_global_error(); |
29 } | 33 } |
30 | 34 |
31 scoped_ptr<TestingProfile> profile_; | 35 scoped_ptr<TestingProfile> profile_; |
32 SigninGlobalError* global_error_; | 36 SigninGlobalError* global_error_; |
33 }; | 37 }; |
34 | 38 |
35 TEST_F(SigninGlobalErrorTest, NoAuthStatusProviders) { | 39 TEST_F(SigninGlobalErrorTest, NoAuthStatusProviders) { |
36 ASSERT_FALSE(global_error_->HasMenuItem()); | 40 ASSERT_FALSE(global_error_->HasMenuItem()); |
37 } | 41 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 // menu item to display auth status/errors. | 120 // menu item to display auth status/errors. |
117 EXPECT_EQ(global_error_->HasMenuItem(), table[i].is_error); | 121 EXPECT_EQ(global_error_->HasMenuItem(), table[i].is_error); |
118 EXPECT_EQ(global_error_->MenuItemLabel().empty(), !table[i].is_error); | 122 EXPECT_EQ(global_error_->MenuItemLabel().empty(), !table[i].is_error); |
119 EXPECT_EQ(global_error_->GetBubbleViewMessages().empty(), | 123 EXPECT_EQ(global_error_->GetBubbleViewMessages().empty(), |
120 !table[i].is_error); | 124 !table[i].is_error); |
121 EXPECT_FALSE(global_error_->GetBubbleViewTitle().empty()); | 125 EXPECT_FALSE(global_error_->GetBubbleViewTitle().empty()); |
122 EXPECT_FALSE(global_error_->GetBubbleViewAcceptButtonLabel().empty()); | 126 EXPECT_FALSE(global_error_->GetBubbleViewAcceptButtonLabel().empty()); |
123 EXPECT_TRUE(global_error_->GetBubbleViewCancelButtonLabel().empty()); | 127 EXPECT_TRUE(global_error_->GetBubbleViewCancelButtonLabel().empty()); |
124 } | 128 } |
125 } | 129 } |
OLD | NEW |