OLD | NEW |
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/base_switches.h" | |
9 #include "base/macros.h" | 8 #include "base/macros.h" |
10 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
11 #include "chrome/browser/extensions/api/instance_id/instance_id_api.h" | 10 #include "chrome/browser/extensions/api/instance_id/instance_id_api.h" |
12 #include "chrome/browser/extensions/extension_apitest.h" | 11 #include "chrome/browser/extensions/extension_apitest.h" |
13 #include "chrome/browser/extensions/extension_gcm_app_handler.h" | 12 #include "chrome/browser/extensions/extension_gcm_app_handler.h" |
14 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/services/gcm/fake_gcm_profile_service.h" | 14 #include "chrome/browser/services/gcm/fake_gcm_profile_service.h" |
16 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" | 15 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" |
17 #include "chrome/browser/services/gcm/instance_id/instance_id_profile_service_fa
ctory.h" | 16 #include "chrome/browser/services/gcm/instance_id/instance_id_profile_service_fa
ctory.h" |
18 #include "chrome/test/base/ui_test_utils.h" | 17 #include "chrome/test/base/ui_test_utils.h" |
(...skipping 16 matching lines...) Expand all Loading... |
35 } | 34 } |
36 | 35 |
37 } // namespace | 36 } // namespace |
38 | 37 |
39 class InstanceIDApiTest : public ExtensionApiTest { | 38 class InstanceIDApiTest : public ExtensionApiTest { |
40 public: | 39 public: |
41 InstanceIDApiTest(); | 40 InstanceIDApiTest(); |
42 | 41 |
43 protected: | 42 protected: |
44 void SetUpOnMainThread() override; | 43 void SetUpOnMainThread() override; |
45 void SetUpCommandLine(base::CommandLine* command_line) override; | |
46 | 44 |
47 private: | 45 private: |
48 DISALLOW_COPY_AND_ASSIGN(InstanceIDApiTest); | 46 DISALLOW_COPY_AND_ASSIGN(InstanceIDApiTest); |
49 }; | 47 }; |
50 | 48 |
51 InstanceIDApiTest::InstanceIDApiTest() { | 49 InstanceIDApiTest::InstanceIDApiTest() { |
52 } | 50 } |
53 | 51 |
54 void InstanceIDApiTest::SetUpOnMainThread() { | 52 void InstanceIDApiTest::SetUpOnMainThread() { |
55 gcm::GCMProfileServiceFactory::GetInstance()->SetTestingFactory( | 53 gcm::GCMProfileServiceFactory::GetInstance()->SetTestingFactory( |
56 browser()->profile(), &BuildFakeGCMProfileService); | 54 browser()->profile(), &BuildFakeGCMProfileService); |
57 | 55 |
58 ExtensionApiTest::SetUpOnMainThread(); | 56 ExtensionApiTest::SetUpOnMainThread(); |
59 } | 57 } |
60 | 58 |
61 void InstanceIDApiTest::SetUpCommandLine(base::CommandLine* command_line) { | |
62 ExtensionApiTest::SetUpCommandLine(command_line); | |
63 | |
64 // Makes sure InstanceID is enabled for testing. | |
65 command_line->AppendSwitchASCII( | |
66 switches::kForceFieldTrials, "InstanceID/Enabled/"); | |
67 } | |
68 | |
69 IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, GetID) { | 59 IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, GetID) { |
70 ASSERT_TRUE(RunExtensionTest("instance_id/get_id")); | 60 ASSERT_TRUE(RunExtensionTest("instance_id/get_id")); |
71 } | 61 } |
72 | 62 |
73 IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, GetCreationTime) { | 63 IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, GetCreationTime) { |
74 ASSERT_TRUE(RunExtensionTest("instance_id/get_creation_time")); | 64 ASSERT_TRUE(RunExtensionTest("instance_id/get_creation_time")); |
75 } | 65 } |
76 | 66 |
77 IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, DeleteID) { | 67 IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, DeleteID) { |
78 ASSERT_TRUE(RunExtensionTest("instance_id/delete_id")); | 68 ASSERT_TRUE(RunExtensionTest("instance_id/delete_id")); |
(...skipping 14 matching lines...) Expand all Loading... |
93 incognito_catcher.RestrictToBrowserContext( | 83 incognito_catcher.RestrictToBrowserContext( |
94 profile()->GetOffTheRecordProfile()); | 84 profile()->GetOffTheRecordProfile()); |
95 | 85 |
96 ASSERT_TRUE(RunExtensionTestIncognito("instance_id/incognito")); | 86 ASSERT_TRUE(RunExtensionTestIncognito("instance_id/incognito")); |
97 | 87 |
98 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 88 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
99 EXPECT_TRUE(incognito_catcher.GetNextResult()) << incognito_catcher.message(); | 89 EXPECT_TRUE(incognito_catcher.GetNextResult()) << incognito_catcher.message(); |
100 } | 90 } |
101 | 91 |
102 } // namespace extensions | 92 } // namespace extensions |
OLD | NEW |