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

Side by Side Diff: chrome/browser/chromeos/login/saml/saml_offline_signin_limiter_unittest.cc

Issue 1086733002: Ensure tests have an active task runner (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 8 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
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/chromeos/login/saml/saml_offline_signin_limiter.h" 5 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter.h"
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/test/simple_test_clock.h" 9 #include "base/test/simple_test_clock.h"
10 #include "base/test/test_simple_task_runner.h" 10 #include "base/test/test_simple_task_runner.h"
11 #include "base/thread_task_runner_handle.h" 11 #include "base/thread_task_runner_handle.h"
12 #include "base/time/clock.h" 12 #include "base/time/clock.h"
13 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter_factory .h" 13 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter_factory .h"
14 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" 14 #include "chrome/browser/chromeos/login/users/mock_user_manager.h"
15 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" 15 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
18 #include "chrome/test/base/testing_browser_process.h"
18 #include "chrome/test/base/testing_profile.h" 19 #include "chrome/test/base/testing_profile.h"
19 #include "components/pref_registry/pref_registry_syncable.h" 20 #include "components/pref_registry/pref_registry_syncable.h"
20 #include "testing/gmock/include/gmock/gmock.h" 21 #include "testing/gmock/include/gmock/gmock.h"
21 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
22 23
23 using testing::Mock; 24 using testing::Mock;
24 using testing::ReturnRef; 25 using testing::ReturnRef;
25 using testing::Sequence; 26 using testing::Sequence;
27 using testing::_;
26 28
27 namespace chromeos { 29 namespace chromeos {
28 30
29 namespace { 31 namespace {
30 const char kTestUser[] = "user@example.com"; 32 const char kTestUser[] = "user@example.com";
31 } 33 }
32 34
33 class SAMLOfflineSigninLimiterTest : public testing::Test { 35 class SAMLOfflineSigninLimiterTest : public testing::Test {
34 protected: 36 protected:
35 SAMLOfflineSigninLimiterTest(); 37 SAMLOfflineSigninLimiterTest();
(...skipping 25 matching lines...) Expand all
61 runner_handle_(runner_), 63 runner_handle_(runner_),
62 user_manager_(new MockUserManager), 64 user_manager_(new MockUserManager),
63 user_manager_enabler_(user_manager_), 65 user_manager_enabler_(user_manager_),
64 limiter_(NULL) { 66 limiter_(NULL) {
65 } 67 }
66 68
67 SAMLOfflineSigninLimiterTest::~SAMLOfflineSigninLimiterTest() { 69 SAMLOfflineSigninLimiterTest::~SAMLOfflineSigninLimiterTest() {
68 DestroyLimiter(); 70 DestroyLimiter();
69 Mock::VerifyAndClearExpectations(user_manager_); 71 Mock::VerifyAndClearExpectations(user_manager_);
70 EXPECT_CALL(*user_manager_, Shutdown()).Times(1); 72 EXPECT_CALL(*user_manager_, Shutdown()).Times(1);
73 EXPECT_CALL(*user_manager_, RemoveSessionStateObserver(_)).Times(1);
74 profile_.reset();
75 TestingBrowserProcess::DeleteInstance();
71 } 76 }
72 77
73 void SAMLOfflineSigninLimiterTest::DestroyLimiter() { 78 void SAMLOfflineSigninLimiterTest::DestroyLimiter() {
74 if (limiter_) { 79 if (limiter_) {
75 limiter_->Shutdown(); 80 limiter_->Shutdown();
76 delete limiter_; 81 delete limiter_;
77 limiter_ = NULL; 82 limiter_ = NULL;
78 } 83 }
79 } 84 }
80 85
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 EXPECT_CALL(*user_manager_, SaveForceOnlineSignin(kTestUser, false)).Times(0); 573 EXPECT_CALL(*user_manager_, SaveForceOnlineSignin(kTestUser, false)).Times(0);
569 EXPECT_CALL(*user_manager_, SaveForceOnlineSignin(kTestUser, true)).Times(1); 574 EXPECT_CALL(*user_manager_, SaveForceOnlineSignin(kTestUser, true)).Times(1);
570 limiter_->SignedIn(UserContext::AUTH_FLOW_OFFLINE); 575 limiter_->SignedIn(UserContext::AUTH_FLOW_OFFLINE);
571 576
572 const base::Time last_gaia_signin_time = base::Time::FromInternalValue( 577 const base::Time last_gaia_signin_time = base::Time::FromInternalValue(
573 prefs->GetInt64(prefs::kSAMLLastGAIASignInTime)); 578 prefs->GetInt64(prefs::kSAMLLastGAIASignInTime));
574 EXPECT_EQ(gaia_signin_time, last_gaia_signin_time); 579 EXPECT_EQ(gaia_signin_time, last_gaia_signin_time);
575 } 580 }
576 581
577 } // namespace chromeos 582 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698