| 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 "base/prefs/pref_service.h" |
| 9 #include "chrome/browser/signin/fake_auth_status_provider.h" | 9 #include "chrome/browser/signin/fake_auth_status_provider.h" |
| 10 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" | 10 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" |
| 11 #include "chrome/browser/signin/fake_profile_oauth2_token_service_wrapper.h" |
| 11 #include "chrome/browser/signin/fake_signin_manager.h" | 12 #include "chrome/browser/signin/fake_signin_manager.h" |
| 12 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 13 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 13 #include "chrome/browser/signin/signin_manager.h" | 14 #include "chrome/browser/signin/signin_manager.h" |
| 14 #include "chrome/browser/signin/signin_manager_factory.h" | 15 #include "chrome/browser/signin/signin_manager_factory.h" |
| 15 #include "chrome/browser/ui/global_error/global_error_service.h" | 16 #include "chrome/browser/ui/global_error/global_error_service.h" |
| 16 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 17 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
| 17 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
| 18 #include "chrome/test/base/testing_profile.h" | 19 #include "chrome/test/base/testing_profile.h" |
| 19 #include "content/public/test/test_browser_thread_bundle.h" | 20 #include "content/public/test/test_browser_thread_bundle.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 21 | 22 |
| 22 static const char kTestAccountId[] = "testuser@test.com"; | 23 static const char kTestAccountId[] = "testuser@test.com"; |
| 23 static const char kOtherTestAccountId[] = "otheruser@test.com"; | 24 static const char kOtherTestAccountId[] = "otheruser@test.com"; |
| 24 | 25 |
| 25 class SigninGlobalErrorTest : public testing::Test { | 26 class SigninGlobalErrorTest : public testing::Test { |
| 26 public: | 27 public: |
| 27 virtual void SetUp() OVERRIDE { | 28 virtual void SetUp() OVERRIDE { |
| 28 // Create a signed-in profile. | 29 // Create a signed-in profile. |
| 29 TestingProfile::Builder builder; | 30 TestingProfile::Builder builder; |
| 30 builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), | 31 builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), |
| 31 FakeProfileOAuth2TokenService::Build); | 32 FakeProfileOAuth2TokenServiceWrapper::Build); |
| 32 builder.AddTestingFactory(SigninManagerFactory::GetInstance(), | 33 builder.AddTestingFactory(SigninManagerFactory::GetInstance(), |
| 33 FakeSigninManagerBase::Build); | 34 FakeSigninManagerBase::Build); |
| 34 profile_ = builder.Build(); | 35 profile_ = builder.Build(); |
| 35 SigninManagerBase* manager = static_cast<SigninManagerBase*>( | 36 SigninManagerBase* manager = static_cast<SigninManagerBase*>( |
| 36 SigninManagerFactory::GetForProfile(profile_.get())); | 37 SigninManagerFactory::GetForProfile(profile_.get())); |
| 37 profile_->GetPrefs()->SetString( | 38 profile_->GetPrefs()->SetString( |
| 38 prefs::kGoogleServicesUsername, kTestAccountId); | 39 prefs::kGoogleServicesUsername, kTestAccountId); |
| 39 manager->Initialize(profile_.get(), NULL); | 40 manager->Initialize(profile_.get(), NULL); |
| 40 global_error_ = SigninGlobalError::GetForProfile(profile_.get()); | 41 global_error_ = SigninGlobalError::GetForProfile(profile_.get()); |
| 41 } | 42 } |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 // menu item to display auth status/errors. | 176 // menu item to display auth status/errors. |
| 176 EXPECT_EQ(global_error_->HasMenuItem(), table[i].is_error); | 177 EXPECT_EQ(global_error_->HasMenuItem(), table[i].is_error); |
| 177 EXPECT_EQ(global_error_->MenuItemLabel().empty(), !table[i].is_error); | 178 EXPECT_EQ(global_error_->MenuItemLabel().empty(), !table[i].is_error); |
| 178 EXPECT_EQ(global_error_->GetBubbleViewMessages().empty(), | 179 EXPECT_EQ(global_error_->GetBubbleViewMessages().empty(), |
| 179 !table[i].is_error); | 180 !table[i].is_error); |
| 180 EXPECT_FALSE(global_error_->GetBubbleViewTitle().empty()); | 181 EXPECT_FALSE(global_error_->GetBubbleViewTitle().empty()); |
| 181 EXPECT_FALSE(global_error_->GetBubbleViewAcceptButtonLabel().empty()); | 182 EXPECT_FALSE(global_error_->GetBubbleViewAcceptButtonLabel().empty()); |
| 182 EXPECT_TRUE(global_error_->GetBubbleViewCancelButtonLabel().empty()); | 183 EXPECT_TRUE(global_error_->GetBubbleViewCancelButtonLabel().empty()); |
| 183 } | 184 } |
| 184 } | 185 } |
| OLD | NEW |