Commit 7aabaf07 authored by Colin Blundell's avatar Colin Blundell Committed by Commit Bot

[GCM] Better organize non-ChromeOS AccountTracker unittests

There are three sections of AccountTracker unittests:
- Primary account only
- Secondary accounts
- Interaction between primary and secondary accounts

In each of these sections, non-ChromeOS tests were scattered throughout.
This CL consolidates the non-ChromeOS tests so that there is one set
of non-ChromeOS tests at the end of each section.

Followup to
https://chromium-review.googlesource.com/c/chromium/src/+/1148200.

Change-Id: I5e89a78a1d493ecd25b75d495969dda68f2b136e
Reviewed-on: https://chromium-review.googlesource.com/1158830
Commit-Queue: Colin Blundell <blundell@chromium.org>
Reviewed-by: default avatarPeter Beverloo <peter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#580120}
parent 2d2c1b14
......@@ -384,6 +384,30 @@ TEST_F(AccountTrackerTest, PrimaryLoginThenTokenAvailable) {
observer()->CheckEvents(TrackingEvent(SIGN_IN, primary_account_id)));
}
TEST_F(AccountTrackerTest, PrimaryRevoke) {
std::string primary_account_id = SetActiveAccount(kPrimaryAccountEmail);
NotifyTokenAvailable(primary_account_id);
ReturnOAuthUrlFetchSuccess(primary_account_id);
observer()->Clear();
NotifyTokenRevoked(primary_account_id);
EXPECT_TRUE(
observer()->CheckEvents(TrackingEvent(SIGN_OUT, primary_account_id)));
}
TEST_F(AccountTrackerTest, PrimaryRevokeThenTokenAvailable) {
std::string primary_account_id = SetActiveAccount(kPrimaryAccountEmail);
NotifyTokenAvailable(primary_account_id);
ReturnOAuthUrlFetchSuccess(primary_account_id);
NotifyTokenRevoked(primary_account_id);
observer()->Clear();
NotifyTokenAvailable(primary_account_id);
EXPECT_TRUE(
observer()->CheckEvents(TrackingEvent(SIGN_IN, primary_account_id)));
}
// These tests exercise true login/logout, which are not possible on ChromeOS.
#if !defined(OS_CHROMEOS)
TEST_F(AccountTrackerTest, PrimaryTokenAvailableThenLogin) {
AddAccountWithToken(kPrimaryAccountEmail);
......@@ -405,21 +429,7 @@ TEST_F(AccountTrackerTest, PrimaryTokenAvailableAndRevokedThenLogin) {
SetActiveAccount(kPrimaryAccountEmail);
EXPECT_TRUE(observer()->CheckEvents());
}
#endif
TEST_F(AccountTrackerTest, PrimaryRevoke) {
std::string primary_account_id = SetActiveAccount(kPrimaryAccountEmail);
NotifyTokenAvailable(primary_account_id);
ReturnOAuthUrlFetchSuccess(primary_account_id);
observer()->Clear();
NotifyTokenRevoked(primary_account_id);
EXPECT_TRUE(
observer()->CheckEvents(TrackingEvent(SIGN_OUT, primary_account_id)));
}
// This test uses a logout flow, not possible on ChromeOS.
#if !defined(OS_CHROMEOS)
TEST_F(AccountTrackerTest, PrimaryRevokeThenLogin) {
std::string primary_account_id = SetActiveAccount(kPrimaryAccountEmail);
NotifyTokenAvailable(primary_account_id);
......@@ -430,22 +440,7 @@ TEST_F(AccountTrackerTest, PrimaryRevokeThenLogin) {
SetActiveAccount(kPrimaryAccountEmail);
EXPECT_TRUE(observer()->CheckEvents());
}
#endif
TEST_F(AccountTrackerTest, PrimaryRevokeThenTokenAvailable) {
std::string primary_account_id = SetActiveAccount(kPrimaryAccountEmail);
NotifyTokenAvailable(primary_account_id);
ReturnOAuthUrlFetchSuccess(primary_account_id);
NotifyTokenRevoked(primary_account_id);
observer()->Clear();
NotifyTokenAvailable(primary_account_id);
EXPECT_TRUE(
observer()->CheckEvents(TrackingEvent(SIGN_IN, primary_account_id)));
}
// These tests exercise true login/logout, which are not possible on ChromeOS.
#if !defined(OS_CHROMEOS)
TEST_F(AccountTrackerTest, PrimaryLogoutThenRevoke) {
std::string primary_account_id = SetActiveAccount(kPrimaryAccountEmail);
NotifyTokenAvailable(primary_account_id);
......@@ -636,24 +631,6 @@ TEST_F(AccountTrackerTest, MultiNoEventsBeforeLogin) {
EXPECT_TRUE(observer()->CheckEvents());
}
// This test exercises true login/logout, which are not possible on ChromeOS.
#if !defined(OS_CHROMEOS)
TEST_F(AccountTrackerTest, MultiLogoutRemovesAllAccounts) {
std::string primary_account_id = SetActiveAccount(kPrimaryAccountEmail);
NotifyTokenAvailable(primary_account_id);
ReturnOAuthUrlFetchSuccess(primary_account_id);
std::string account_id = AddAccountWithToken("user@example.com");
ReturnOAuthUrlFetchSuccess(account_id);
observer()->Clear();
NotifyLogoutOfAllAccounts();
observer()->SortEventsByUser();
EXPECT_TRUE(
observer()->CheckEvents(TrackingEvent(SIGN_OUT, primary_account_id),
TrackingEvent(SIGN_OUT, account_id)));
}
#endif
TEST_F(AccountTrackerTest, MultiRevokePrimaryDoesNotRemoveAllAccounts) {
std::string primary_account_id = SetActiveAccount(kPrimaryAccountEmail);
NotifyTokenAvailable(primary_account_id);
......@@ -731,4 +708,22 @@ TEST_F(AccountTrackerTest, GetAccountsReturnNothingWhenPrimarySignedOut) {
EXPECT_EQ(0ul, ids.size());
}
// This test exercises true login/logout, which are not possible on ChromeOS.
#if !defined(OS_CHROMEOS)
TEST_F(AccountTrackerTest, MultiLogoutRemovesAllAccounts) {
std::string primary_account_id = SetActiveAccount(kPrimaryAccountEmail);
NotifyTokenAvailable(primary_account_id);
ReturnOAuthUrlFetchSuccess(primary_account_id);
std::string account_id = AddAccountWithToken("user@example.com");
ReturnOAuthUrlFetchSuccess(account_id);
observer()->Clear();
NotifyLogoutOfAllAccounts();
observer()->SortEventsByUser();
EXPECT_TRUE(
observer()->CheckEvents(TrackingEvent(SIGN_OUT, primary_account_id),
TrackingEvent(SIGN_OUT, account_id)));
}
#endif
} // namespace gcm
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment