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