OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/run_loop.h" |
| 6 #include "chrome/browser/extensions/api/instance_id/instance_id_api.h" |
| 7 #include "chrome/browser/extensions/extension_apitest.h" |
| 8 #include "chrome/browser/extensions/extension_gcm_app_handler.h" |
| 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/services/gcm/fake_gcm_profile_service.h" |
| 11 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" |
| 12 #include "chrome/browser/services/gcm/instance_id/instance_id_profile_service_fa
ctory.h" |
| 13 #include "chrome/common/chrome_switches.h" |
| 14 #include "chrome/test/base/ui_test_utils.h" |
| 15 #include "extensions/test/result_catcher.h" |
| 16 |
| 17 using extensions::ResultCatcher; |
| 18 |
| 19 namespace extensions { |
| 20 |
| 21 class InstanceIDApiTest : public ExtensionApiTest { |
| 22 public: |
| 23 InstanceIDApiTest() {} |
| 24 |
| 25 protected: |
| 26 void SetUpOnMainThread() override; |
| 27 void SetUpCommandLine(base::CommandLine* command_line) override; |
| 28 |
| 29 private: |
| 30 DISALLOW_COPY_AND_ASSIGN(InstanceIDApiTest); |
| 31 }; |
| 32 |
| 33 void InstanceIDApiTest::SetUpOnMainThread() { |
| 34 gcm::GCMProfileServiceFactory::GetInstance()->SetTestingFactory( |
| 35 browser()->profile(), &gcm::FakeGCMProfileService::Build); |
| 36 |
| 37 ExtensionApiTest::SetUpOnMainThread(); |
| 38 } |
| 39 |
| 40 void InstanceIDApiTest::SetUpCommandLine(base::CommandLine* command_line) { |
| 41 ExtensionApiTest::SetUpCommandLine(command_line); |
| 42 |
| 43 // Makes sure InstanceID is enabled for testing. |
| 44 command_line->AppendSwitchASCII( |
| 45 switches::kForceFieldTrials, "InstanceID/Enabled/"); |
| 46 } |
| 47 |
| 48 IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, GetID) { |
| 49 ASSERT_TRUE(RunExtensionTest("instance_id/get_id")); |
| 50 } |
| 51 |
| 52 IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, GetCreationTime) { |
| 53 ASSERT_TRUE(RunExtensionTest("instance_id/get_creation_time")); |
| 54 } |
| 55 |
| 56 IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, DeleteID) { |
| 57 ASSERT_TRUE(RunExtensionTest("instance_id/delete_id")); |
| 58 } |
| 59 |
| 60 IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, GetToken) { |
| 61 ASSERT_TRUE(RunExtensionTest("instance_id/get_token")); |
| 62 } |
| 63 |
| 64 IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, DeleteToken) { |
| 65 ASSERT_TRUE(RunExtensionTest("instance_id/delete_token")); |
| 66 } |
| 67 |
| 68 IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, Incognito) { |
| 69 ResultCatcher catcher; |
| 70 catcher.RestrictToBrowserContext(profile()); |
| 71 ResultCatcher incognito_catcher; |
| 72 incognito_catcher.RestrictToBrowserContext( |
| 73 profile()->GetOffTheRecordProfile()); |
| 74 |
| 75 ASSERT_TRUE(RunExtensionTestIncognito("instance_id/incognito")); |
| 76 |
| 77 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 78 EXPECT_TRUE(incognito_catcher.GetNextResult()) << incognito_catcher.message(); |
| 79 } |
| 80 |
| 81 } // namespace extensions |
OLD | NEW |