#include <memory>
#include <vector>
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/thread_pool.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/gcm/gcm_product_util.h"
#include "chrome/browser/gcm/gcm_profile_service_factory.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/common/channel_info.h"
#include "chrome/test/base/testing_profile.h"
#include "components/gcm_driver/fake_gcm_app_handler.h"
#include "components/gcm_driver/fake_gcm_client.h"
#include "components/gcm_driver/fake_gcm_client_factory.h"
#include "components/gcm_driver/gcm_client.h"
#include "components/gcm_driver/gcm_client_factory.h"
#include "components/gcm_driver/gcm_driver.h"
#include "components/gcm_driver/gcm_profile_service.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/test/browser_task_environment.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/mojom/network_context.mojom.h"
#include "services/network/test/test_network_connection_tracker.h"
#include "testing/gtest/include/gtest/gtest.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chromeos/ash/components/dbus/concierge/concierge_client.h"
#endif
namespace gcm {
namespace {
const char kTestAppID[] = …;
const char kUserID[] = …;
void RequestProxyResolvingSocketFactoryOnUIThread(
Profile* profile,
base::WeakPtr<gcm::GCMProfileService> service,
mojo::PendingReceiver<network::mojom::ProxyResolvingSocketFactory>
receiver) { … }
void RequestProxyResolvingSocketFactory(
Profile* profile,
base::WeakPtr<gcm::GCMProfileService> service,
mojo::PendingReceiver<network::mojom::ProxyResolvingSocketFactory>
receiver) { … }
std::unique_ptr<KeyedService> BuildGCMProfileService(
content::BrowserContext* context) { … }
}
class GCMProfileServiceTest : public testing::Test { … };
GCMProfileServiceTest::GCMProfileServiceTest()
: … { … }
GCMProfileServiceTest::~GCMProfileServiceTest() { … }
FakeGCMClient* GCMProfileServiceTest::GetGCMClient() const { … }
void GCMProfileServiceTest::SetUp() { … }
void GCMProfileServiceTest::TearDown() { … }
void GCMProfileServiceTest::CreateGCMProfileService() { … }
void GCMProfileServiceTest::RegisterAndWaitForCompletion(
const std::vector<std::string>& sender_ids) { … }
void GCMProfileServiceTest::UnregisterAndWaitForCompletion() { … }
void GCMProfileServiceTest::SendAndWaitForCompletion(
const OutgoingMessage& message) { … }
void GCMProfileServiceTest::RegisterCompleted(
base::OnceClosure callback,
const std::string& registration_id,
GCMClient::Result result) { … }
void GCMProfileServiceTest::UnregisterCompleted(base::OnceClosure callback,
GCMClient::Result result) { … }
void GCMProfileServiceTest::SendCompleted(base::OnceClosure callback,
const std::string& message_id,
GCMClient::Result result) { … }
TEST_F(GCMProfileServiceTest, RegisterAndUnregister) { … }
TEST_F(GCMProfileServiceTest, Send) { … }
}