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 "base/run_loop.h" | 5 #include "base/run_loop.h" |
6 #include "chrome/browser/extensions/api/instance_id/instance_id_api.h" | 6 #include "chrome/browser/extensions/api/instance_id/instance_id_api.h" |
7 #include "chrome/browser/extensions/extension_apitest.h" | 7 #include "chrome/browser/extensions/extension_apitest.h" |
8 #include "chrome/browser/extensions/extension_gcm_app_handler.h" | 8 #include "chrome/browser/extensions/extension_gcm_app_handler.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/services/gcm/fake_gcm_profile_service.h" | 10 #include "chrome/browser/services/gcm/fake_gcm_profile_service.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 gcm::FakeGCMProfileService* service = | 25 gcm::FakeGCMProfileService* service = |
26 new gcm::FakeGCMProfileService(Profile::FromBrowserContext(context)); | 26 new gcm::FakeGCMProfileService(Profile::FromBrowserContext(context)); |
27 service->SetDriverForTesting(new instance_id::FakeGCMDriverForInstanceID()); | 27 service->SetDriverForTesting(new instance_id::FakeGCMDriverForInstanceID()); |
28 return service; | 28 return service; |
29 } | 29 } |
30 | 30 |
31 } // namespace | 31 } // namespace |
32 | 32 |
33 class InstanceIDApiTest : public ExtensionApiTest { | 33 class InstanceIDApiTest : public ExtensionApiTest { |
34 public: | 34 public: |
35 InstanceIDApiTest() {} | 35 InstanceIDApiTest(); |
36 | 36 |
37 protected: | 37 protected: |
38 void SetUpOnMainThread() override; | 38 void SetUpOnMainThread() override; |
39 | 39 |
40 private: | 40 private: |
| 41 extensions::ScopedCurrentChannel current_channel_; |
| 42 |
41 DISALLOW_COPY_AND_ASSIGN(InstanceIDApiTest); | 43 DISALLOW_COPY_AND_ASSIGN(InstanceIDApiTest); |
42 }; | 44 }; |
43 | 45 |
| 46 InstanceIDApiTest::InstanceIDApiTest() |
| 47 : current_channel_(chrome::VersionInfo::CHANNEL_DEV) { |
| 48 } |
| 49 |
44 void InstanceIDApiTest::SetUpOnMainThread() { | 50 void InstanceIDApiTest::SetUpOnMainThread() { |
45 gcm::GCMProfileServiceFactory::GetInstance()->SetTestingFactory( | 51 gcm::GCMProfileServiceFactory::GetInstance()->SetTestingFactory( |
46 browser()->profile(), &BuildFakeGCMProfileService); | 52 browser()->profile(), &BuildFakeGCMProfileService); |
47 | 53 |
48 ExtensionApiTest::SetUpOnMainThread(); | 54 ExtensionApiTest::SetUpOnMainThread(); |
49 } | 55 } |
50 | 56 |
51 IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, GetID) { | 57 IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, GetID) { |
52 extensions::ScopedCurrentChannel current_channel( | |
53 chrome::VersionInfo::CHANNEL_DEV); | |
54 ASSERT_TRUE(RunExtensionTest("instance_id/get_id")); | 58 ASSERT_TRUE(RunExtensionTest("instance_id/get_id")); |
55 } | 59 } |
56 | 60 |
57 IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, GetCreationTime) { | 61 IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, GetCreationTime) { |
58 extensions::ScopedCurrentChannel current_channel( | |
59 chrome::VersionInfo::CHANNEL_DEV); | |
60 ASSERT_TRUE(RunExtensionTest("instance_id/get_creation_time")); | 62 ASSERT_TRUE(RunExtensionTest("instance_id/get_creation_time")); |
61 } | 63 } |
62 | 64 |
63 IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, DeleteID) { | 65 IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, DeleteID) { |
64 extensions::ScopedCurrentChannel current_channel( | |
65 chrome::VersionInfo::CHANNEL_DEV); | |
66 ASSERT_TRUE(RunExtensionTest("instance_id/delete_id")); | 66 ASSERT_TRUE(RunExtensionTest("instance_id/delete_id")); |
67 } | 67 } |
68 | 68 |
69 IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, GetToken) { | 69 IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, GetToken) { |
70 extensions::ScopedCurrentChannel current_channel( | |
71 chrome::VersionInfo::CHANNEL_DEV); | |
72 ASSERT_TRUE(RunExtensionTest("instance_id/get_token")); | 70 ASSERT_TRUE(RunExtensionTest("instance_id/get_token")); |
73 } | 71 } |
74 | 72 |
75 IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, DeleteToken) { | 73 IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, DeleteToken) { |
76 extensions::ScopedCurrentChannel current_channel( | |
77 chrome::VersionInfo::CHANNEL_DEV); | |
78 ASSERT_TRUE(RunExtensionTest("instance_id/delete_token")); | 74 ASSERT_TRUE(RunExtensionTest("instance_id/delete_token")); |
79 } | 75 } |
80 | 76 |
81 IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, Incognito) { | 77 IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, Incognito) { |
82 extensions::ScopedCurrentChannel current_channel( | |
83 chrome::VersionInfo::CHANNEL_DEV); | |
84 | |
85 ResultCatcher catcher; | 78 ResultCatcher catcher; |
86 catcher.RestrictToBrowserContext(profile()); | 79 catcher.RestrictToBrowserContext(profile()); |
87 ResultCatcher incognito_catcher; | 80 ResultCatcher incognito_catcher; |
88 incognito_catcher.RestrictToBrowserContext( | 81 incognito_catcher.RestrictToBrowserContext( |
89 profile()->GetOffTheRecordProfile()); | 82 profile()->GetOffTheRecordProfile()); |
90 | 83 |
91 ASSERT_TRUE(RunExtensionTestIncognito("instance_id/incognito")); | 84 ASSERT_TRUE(RunExtensionTestIncognito("instance_id/incognito")); |
92 | 85 |
93 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 86 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
94 EXPECT_TRUE(incognito_catcher.GetNextResult()) << incognito_catcher.message(); | 87 EXPECT_TRUE(incognito_catcher.GetNextResult()) << incognito_catcher.message(); |
95 } | 88 } |
96 | 89 |
97 IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, BetaChannel) { | 90 IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, BetaChannel) { |
98 extensions::ScopedCurrentChannel current_channel( | 91 extensions::ScopedCurrentChannel current_channel_override( |
99 chrome::VersionInfo::CHANNEL_BETA); | 92 chrome::VersionInfo::CHANNEL_BETA); |
100 ASSERT_TRUE(RunExtensionTest("instance_id/channel")); | 93 ASSERT_TRUE(RunExtensionTest("instance_id/channel")); |
101 } | 94 } |
102 | 95 |
103 IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, StableChannel) { | 96 IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, StableChannel) { |
104 extensions::ScopedCurrentChannel current_channel( | 97 extensions::ScopedCurrentChannel current_channel_override( |
105 chrome::VersionInfo::CHANNEL_STABLE); | 98 chrome::VersionInfo::CHANNEL_STABLE); |
106 ASSERT_TRUE(RunExtensionTest("instance_id/channel")); | 99 ASSERT_TRUE(RunExtensionTest("instance_id/channel")); |
107 } | 100 } |
108 | 101 |
109 } // namespace extensions | 102 } // namespace extensions |
OLD | NEW |