| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/stl_util.h" |
| 6 #include "chrome/browser/extensions/api/gcm/gcm_api.h" | 7 #include "chrome/browser/extensions/api/gcm/gcm_api.h" |
| 7 #include "chrome/browser/extensions/extension_apitest.h" | 8 #include "chrome/browser/extensions/extension_apitest.h" |
| 8 #include "chrome/browser/extensions/extension_gcm_app_handler.h" | 9 #include "chrome/browser/extensions/extension_gcm_app_handler.h" |
| 9 #include "chrome/browser/gcm/fake_gcm_profile_service.h" | 10 #include "chrome/browser/gcm/fake_gcm_profile_service.h" |
| 10 #include "chrome/browser/gcm/gcm_profile_service_factory.h" | 11 #include "chrome/browser/gcm/gcm_profile_service_factory.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
| 13 #include "chrome/test/base/ui_test_utils.h" | 14 #include "chrome/test/base/ui_test_utils.h" |
| 14 #include "components/browser_sync/browser_sync_switches.h" | 15 #include "components/browser_sync/browser_sync_switches.h" |
| 15 #include "extensions/test/result_catcher.h" | 16 #include "extensions/test/result_catcher.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 IN_PROC_BROWSER_TEST_F(GcmApiTest, RegisterValidation) { | 117 IN_PROC_BROWSER_TEST_F(GcmApiTest, RegisterValidation) { |
| 117 ASSERT_TRUE(RunExtensionTest("gcm/functions/register_validation")); | 118 ASSERT_TRUE(RunExtensionTest("gcm/functions/register_validation")); |
| 118 } | 119 } |
| 119 | 120 |
| 120 IN_PROC_BROWSER_TEST_F(GcmApiTest, Register) { | 121 IN_PROC_BROWSER_TEST_F(GcmApiTest, Register) { |
| 121 StartCollecting(); | 122 StartCollecting(); |
| 122 ASSERT_TRUE(RunExtensionTest("gcm/functions/register")); | 123 ASSERT_TRUE(RunExtensionTest("gcm/functions/register")); |
| 123 | 124 |
| 124 const std::vector<std::string>& sender_ids = | 125 const std::vector<std::string>& sender_ids = |
| 125 service()->last_registered_sender_ids(); | 126 service()->last_registered_sender_ids(); |
| 126 EXPECT_TRUE(std::find(sender_ids.begin(), sender_ids.end(), "Sender1") != | 127 EXPECT_TRUE(base::ContainsValue(sender_ids, "Sender1")); |
| 127 sender_ids.end()); | 128 EXPECT_TRUE(base::ContainsValue(sender_ids, "Sender2")); |
| 128 EXPECT_TRUE(std::find(sender_ids.begin(), sender_ids.end(), "Sender2") != | |
| 129 sender_ids.end()); | |
| 130 } | 129 } |
| 131 | 130 |
| 132 IN_PROC_BROWSER_TEST_F(GcmApiTest, Unregister) { | 131 IN_PROC_BROWSER_TEST_F(GcmApiTest, Unregister) { |
| 133 service()->AddExpectedUnregisterResponse(gcm::GCMClient::SUCCESS); | 132 service()->AddExpectedUnregisterResponse(gcm::GCMClient::SUCCESS); |
| 134 service()->AddExpectedUnregisterResponse(gcm::GCMClient::SERVER_ERROR); | 133 service()->AddExpectedUnregisterResponse(gcm::GCMClient::SERVER_ERROR); |
| 135 | 134 |
| 136 ASSERT_TRUE(RunExtensionTest("gcm/functions/unregister")); | 135 ASSERT_TRUE(RunExtensionTest("gcm/functions/unregister")); |
| 137 } | 136 } |
| 138 | 137 |
| 139 IN_PROC_BROWSER_TEST_F(GcmApiTest, SendValidation) { | 138 IN_PROC_BROWSER_TEST_F(GcmApiTest, SendValidation) { |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 incognito_catcher.RestrictToBrowserContext( | 258 incognito_catcher.RestrictToBrowserContext( |
| 260 profile()->GetOffTheRecordProfile()); | 259 profile()->GetOffTheRecordProfile()); |
| 261 | 260 |
| 262 ASSERT_TRUE(RunExtensionTestIncognito("gcm/functions/incognito")); | 261 ASSERT_TRUE(RunExtensionTestIncognito("gcm/functions/incognito")); |
| 263 | 262 |
| 264 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 263 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 265 EXPECT_TRUE(incognito_catcher.GetNextResult()) << incognito_catcher.message(); | 264 EXPECT_TRUE(incognito_catcher.GetNextResult()) << incognito_catcher.message(); |
| 266 } | 265 } |
| 267 | 266 |
| 268 } // namespace extensions | 267 } // namespace extensions |
| OLD | NEW |