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

Unified Diff: chrome/browser/policy/device_token_fetcher_unittest.cc

Issue 4960003: Don't register gmail users at the device management server (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 10 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/policy/device_token_fetcher_unittest.cc
diff --git a/chrome/browser/policy/device_token_fetcher_unittest.cc b/chrome/browser/policy/device_token_fetcher_unittest.cc
index 8a408d60f191d638f0847a8fbf018b6ec5ab8df6..b0b1fa11a30b3ee52e917e5b23ff74ae42a03f3f 100644
--- a/chrome/browser/policy/device_token_fetcher_unittest.cc
+++ b/chrome/browser/policy/device_token_fetcher_unittest.cc
@@ -49,9 +49,9 @@ class DeviceTokenFetcherTest : public testing::Test {
loop_.RunAllPending();
}
- void SimulateSuccessfulLoginAndRunPending() {
+ void SimulateSuccessfulLoginAndRunPending(const std::string& username) {
loop_.RunAllPending();
- SimulateSuccessfulLogin();
+ SimulateSuccessfulLogin(fetcher_.get(), username);
loop_.RunAllPending();
}
@@ -81,14 +81,14 @@ TEST_F(DeviceTokenFetcherTest, IsPending) {
ASSERT_TRUE(fetcher_->IsTokenPending());
backend_->AllShouldSucceed();
EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).Times(1);
- SimulateSuccessfulLoginAndRunPending();
+ SimulateSuccessfulLoginAndRunPending(kTestDasherDomainUsername);
ASSERT_FALSE(fetcher_->IsTokenPending());
}
TEST_F(DeviceTokenFetcherTest, SimpleFetchSingleLogin) {
backend_->AllShouldSucceed();
EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).Times(1);
- SimulateSuccessfulLoginAndRunPending();
+ SimulateSuccessfulLoginAndRunPending(kTestDasherDomainUsername);
ASSERT_FALSE(fetcher_->IsTokenPending());
ASSERT_TRUE(fetcher_->IsTokenValid());
const std::string token(fetcher_->GetDeviceToken());
@@ -98,12 +98,12 @@ TEST_F(DeviceTokenFetcherTest, SimpleFetchSingleLogin) {
TEST_F(DeviceTokenFetcherTest, SimpleFetchDoubleLogin) {
backend_->AllShouldSucceed();
EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).Times(1);
- SimulateSuccessfulLoginAndRunPending();
+ SimulateSuccessfulLoginAndRunPending(kTestDasherDomainUsername);
ASSERT_FALSE(fetcher_->IsTokenPending());
const std::string token(fetcher_->GetDeviceToken());
EXPECT_NE("", token);
- SimulateSuccessfulLoginAndRunPending();
+ SimulateSuccessfulLoginAndRunPending(kTestDasherDomainUsername);
ASSERT_FALSE(fetcher_->IsTokenPending());
const std::string token2(fetcher_->GetDeviceToken());
EXPECT_NE("", token2);
@@ -119,7 +119,7 @@ TEST_F(DeviceTokenFetcherTest, FetchBetweenBrowserLaunchAndNotify) {
EXPECT_CALL(observer, Observe(_, _, _)).Times(1);
backend_->AllShouldSucceed();
EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).Times(1);
- SimulateSuccessfulLoginAndRunPending();
+ SimulateSuccessfulLoginAndRunPending(kTestDasherDomainUsername);
ASSERT_FALSE(fetcher_->IsTokenPending());
const std::string token(fetcher_->GetDeviceToken());
EXPECT_NE("", token);
@@ -141,10 +141,28 @@ TEST_F(DeviceTokenFetcherTest, FetchBetweenBrowserLaunchAndNotify) {
TEST_F(DeviceTokenFetcherTest, FailedServerRequest) {
backend_->AllShouldFail();
EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).Times(1);
- SimulateSuccessfulLoginAndRunPending();
+ SimulateSuccessfulLoginAndRunPending(kTestDasherDomainUsername);
ASSERT_FALSE(fetcher_->IsTokenPending());
const std::string token(fetcher_->GetDeviceToken());
EXPECT_EQ("", token);
}
+TEST_F(DeviceTokenFetcherTest, FetchBetweenTokenNotifyAndLoginNotify) {
+ backend_->AllShouldSucceed();
+ EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).Times(0);
+ SimulateSuccessfulLoginAndRunPending("___@gmail.com");
+ ASSERT_TRUE(fetcher_->IsTokenPending());
+ ASSERT_FALSE(fetcher_->IsTokenValid());
+}
+
+TEST_F(DeviceTokenFetcherTest, FetchWithNonDasherUsername) {
+ backend_->AllShouldSucceed();
+ EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).Times(0);
+ loop_.RunAllPending();
+ SimulateTokenAvailable(); // Token is available but user name is not.
+ loop_.RunAllPending();
+ ASSERT_TRUE(fetcher_->IsTokenPending());
+ ASSERT_FALSE(fetcher_->IsTokenValid());
+}
+
} // namespace policy

Powered by Google App Engine
This is Rietveld 408576698