chromium/components/gcm_driver/gcm_account_tracker_unittest.cc

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/gcm_driver/gcm_account_tracker.h"

#include <map>
#include <memory>
#include <string>
#include <utility>

#include "base/memory/raw_ptr.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "build/chromeos_buildflags.h"
#include "components/gcm_driver/fake_gcm_driver.h"
#include "components/signin/public/identity_manager/identity_test_environment.h"
#include "google_apis/gaia/google_service_auth_error.h"
#include "net/base/ip_endpoint.h"
#include "net/http/http_status_code.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "services/network/test/test_url_loader_factory.h"
#include "services/network/test/test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace gcm {

namespace {

const char kEmail1[] =;
const char kEmail2[] =;

std::string MakeAccessToken(const CoreAccountId& account_id) {}

GCMClient::AccountTokenInfo MakeAccountToken(const CoreAccountInfo& account) {}

void VerifyAccountTokens(
    const std::vector<GCMClient::AccountTokenInfo>& expected_tokens,
    const std::vector<GCMClient::AccountTokenInfo>& actual_tokens) {}

// This version of FakeGCMDriver is customized around handling accounts and
// connection events for testing GCMAccountTracker.
class CustomFakeGCMDriver : public FakeGCMDriver {};

CustomFakeGCMDriver::CustomFakeGCMDriver()
    :{}

CustomFakeGCMDriver::~CustomFakeGCMDriver() {}

void CustomFakeGCMDriver::SetAccountTokens(
    const std::vector<GCMClient::AccountTokenInfo>& accounts) {}

void CustomFakeGCMDriver::AddConnectionObserver(
    GCMConnectionObserver* observer) {}

void CustomFakeGCMDriver::RemoveConnectionObserver(
    GCMConnectionObserver* observer) {}

void CustomFakeGCMDriver::SetConnected(bool connected) {}

void CustomFakeGCMDriver::ResetResults() {}


base::Time CustomFakeGCMDriver::GetLastTokenFetchTime() {}

void CustomFakeGCMDriver::SetLastTokenFetchTime(const base::Time& time) {}

}  // namespace

class GCMAccountTrackerTest : public testing::Test {};

GCMAccountTrackerTest::GCMAccountTrackerTest() {}

GCMAccountTrackerTest::~GCMAccountTrackerTest() {}

CoreAccountInfo GCMAccountTrackerTest::AddAccount(const std::string& email) {}

CoreAccountInfo GCMAccountTrackerTest::SetPrimaryAccount(
    const std::string& email) {}

void GCMAccountTrackerTest::ClearPrimaryAccount() {}

void GCMAccountTrackerTest::RemoveAccount(const CoreAccountId& account_id) {}

void GCMAccountTrackerTest::IssueAccessToken(const CoreAccountId& account_id) {}

void GCMAccountTrackerTest::IssueExpiredAccessToken(
    const CoreAccountId& account_id) {}

void GCMAccountTrackerTest::IssueError(const CoreAccountId& account_id) {}

bool GCMAccountTrackerTest::IsFetchingRequired() const {}

bool GCMAccountTrackerTest::IsTokenReportingRequired() const {}

base::TimeDelta GCMAccountTrackerTest::GetTimeToNextTokenReporting() const {}

TEST_F(GCMAccountTrackerTest, NoAccounts) {}

// Verifies that callback is called after a token is issued for a single account
// with a specific scope. In this scenario, the underlying account tracker is
// still working when the CompleteCollectingTokens is called for the first time.
TEST_F(GCMAccountTrackerTest, SingleAccount) {}

TEST_F(GCMAccountTrackerTest, MultipleAccounts) {}

TEST_F(GCMAccountTrackerTest, AccountAdded) {}

TEST_F(GCMAccountTrackerTest, AccountRemoved) {}

#if !BUILDFLAG(IS_CHROMEOS_ASH)
// Tests that clearing the primary account when having multiple accounts
// does not crash the application.
// Regression test for crbug.com/1234406
TEST_F(GCMAccountTrackerTest, AccountRemovedWithoutSyncConsentNoCrash) {}
#endif  // !BUILDFLAG(IS_CHROMEOS_ASH)

TEST_F(GCMAccountTrackerTest, GetTokenFailed) {}

TEST_F(GCMAccountTrackerTest, GetTokenFailedAccountRemoved) {}

TEST_F(GCMAccountTrackerTest, AccountRemovedWhileRequestsPending) {}

// Makes sure that tracker observes GCM connection when running.
TEST_F(GCMAccountTrackerTest, TrackerObservesConnection) {}

// Makes sure that token fetching happens only after connection is established.
TEST_F(GCMAccountTrackerTest, PostponeTokenFetchingUntilConnected) {}

TEST_F(GCMAccountTrackerTest, InvalidateExpiredTokens) {}

// Testing for whether there are still more tokens to be fetched. Typically the
// need for token fetching triggers immediate request, unless there is no
// connection, that is why connection is set on and off in this test.
TEST_F(GCMAccountTrackerTest, IsTokenFetchingRequired) {}

// Tests what is the expected time to the next token fetching.
TEST_F(GCMAccountTrackerTest, GetTimeToNextTokenReporting) {}

// Tests conditions when token reporting is required.
TEST_F(GCMAccountTrackerTest, IsTokenReportingRequired) {}

// TODO(fgorski): Add test for adding account after removal >> make sure it does
// not mark removal.

}  // namespace gcm