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

Side by Side Diff: chrome/browser/extensions/api/instance_id/instance_id_apitest.cc

Issue 2122603007: Move FakeGCMProfileService to components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mo' fix Created 4 years, 5 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <memory> 5 #include <memory>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "chrome/browser/extensions/api/instance_id/instance_id_api.h" 10 #include "chrome/browser/extensions/api/instance_id/instance_id_api.h"
11 #include "chrome/browser/extensions/extension_apitest.h" 11 #include "chrome/browser/extensions/extension_apitest.h"
12 #include "chrome/browser/extensions/extension_gcm_app_handler.h" 12 #include "chrome/browser/extensions/extension_gcm_app_handler.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/services/gcm/fake_gcm_profile_service.h"
15 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" 14 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h"
16 #include "chrome/browser/services/gcm/instance_id/instance_id_profile_service_fa ctory.h" 15 #include "chrome/browser/services/gcm/instance_id/instance_id_profile_service_fa ctory.h"
17 #include "chrome/test/base/ui_test_utils.h" 16 #include "chrome/test/base/ui_test_utils.h"
17 #include "components/gcm_driver/fake_gcm_profile_service.h"
18 #include "components/gcm_driver/instance_id/fake_gcm_driver_for_instance_id.h" 18 #include "components/gcm_driver/instance_id/fake_gcm_driver_for_instance_id.h"
19 #include "components/version_info/version_info.h" 19 #include "components/version_info/version_info.h"
20 #include "extensions/test/result_catcher.h" 20 #include "extensions/test/result_catcher.h"
21 21
22 using extensions::ResultCatcher; 22 using extensions::ResultCatcher;
23 23
24 namespace extensions { 24 namespace extensions {
25 25
26 namespace {
27
28 std::unique_ptr<KeyedService> BuildFakeGCMProfileService(
29 content::BrowserContext* context) {
30 std::unique_ptr<gcm::FakeGCMProfileService> service(
31 new gcm::FakeGCMProfileService(Profile::FromBrowserContext(context)));
32 service->SetDriverForTesting(new instance_id::FakeGCMDriverForInstanceID());
kbalazs 2016/07/14 23:14:46 FYI, this is why the tests failed. This Build* var
33 return std::move(service);
34 }
35
36 } // namespace
37
38 class InstanceIDApiTest : public ExtensionApiTest { 26 class InstanceIDApiTest : public ExtensionApiTest {
39 public: 27 public:
40 InstanceIDApiTest(); 28 InstanceIDApiTest();
41 29
42 protected: 30 protected:
43 void SetUpOnMainThread() override; 31 void SetUpOnMainThread() override;
44 32
45 private: 33 private:
46 DISALLOW_COPY_AND_ASSIGN(InstanceIDApiTest); 34 DISALLOW_COPY_AND_ASSIGN(InstanceIDApiTest);
47 }; 35 };
48 36
49 InstanceIDApiTest::InstanceIDApiTest() { 37 InstanceIDApiTest::InstanceIDApiTest() {
50 } 38 }
51 39
52 void InstanceIDApiTest::SetUpOnMainThread() { 40 void InstanceIDApiTest::SetUpOnMainThread() {
53 gcm::GCMProfileServiceFactory::GetInstance()->SetTestingFactory( 41 gcm::GCMProfileServiceFactory::GetInstance()->SetTestingFactory(
54 browser()->profile(), &BuildFakeGCMProfileService); 42 browser()->profile(), &gcm::FakeGCMProfileService::Build);
55 43
56 ExtensionApiTest::SetUpOnMainThread(); 44 ExtensionApiTest::SetUpOnMainThread();
57 } 45 }
58 46
59 IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, GetID) { 47 IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, GetID) {
60 ASSERT_TRUE(RunExtensionTest("instance_id/get_id")); 48 ASSERT_TRUE(RunExtensionTest("instance_id/get_id"));
61 } 49 }
62 50
63 IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, GetCreationTime) { 51 IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, GetCreationTime) {
64 ASSERT_TRUE(RunExtensionTest("instance_id/get_creation_time")); 52 ASSERT_TRUE(RunExtensionTest("instance_id/get_creation_time"));
(...skipping 18 matching lines...) Expand all
83 incognito_catcher.RestrictToBrowserContext( 71 incognito_catcher.RestrictToBrowserContext(
84 profile()->GetOffTheRecordProfile()); 72 profile()->GetOffTheRecordProfile());
85 73
86 ASSERT_TRUE(RunExtensionTestIncognito("instance_id/incognito")); 74 ASSERT_TRUE(RunExtensionTestIncognito("instance_id/incognito"));
87 75
88 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 76 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
89 EXPECT_TRUE(incognito_catcher.GetNextResult()) << incognito_catcher.message(); 77 EXPECT_TRUE(incognito_catcher.GetNextResult()) << incognito_catcher.message();
90 } 78 }
91 79
92 } // namespace extensions 80 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/gcm/gcm_apitest.cc ('k') | chrome/browser/extensions/service_worker_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698