| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/extensions/extension_gcm_app_handler.h" | 5 #include "chrome/browser/extensions/extension_gcm_app_handler.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
| 14 #include "base/files/scoped_temp_dir.h" | 14 #include "base/files/scoped_temp_dir.h" |
| 15 #include "base/location.h" | 15 #include "base/location.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 18 #include "base/memory/scoped_ptr.h" |
| 18 #include "base/message_loop/message_loop.h" | 19 #include "base/message_loop/message_loop.h" |
| 19 #include "base/path_service.h" | 20 #include "base/path_service.h" |
| 20 #include "base/run_loop.h" | 21 #include "base/run_loop.h" |
| 21 #include "base/values.h" | 22 #include "base/values.h" |
| 22 #include "chrome/browser/chrome_notification_types.h" | 23 #include "chrome/browser/chrome_notification_types.h" |
| 23 #include "chrome/browser/extensions/api/gcm/gcm_api.h" | 24 #include "chrome/browser/extensions/api/gcm/gcm_api.h" |
| 24 #include "chrome/browser/extensions/extension_service.h" | 25 #include "chrome/browser/extensions/extension_service.h" |
| 25 #include "chrome/browser/extensions/test_extension_service.h" | 26 #include "chrome/browser/extensions/test_extension_service.h" |
| 26 #include "chrome/browser/extensions/test_extension_system.h" | 27 #include "chrome/browser/extensions/test_extension_system.h" |
| 27 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 Waiter* waiter_; | 181 Waiter* waiter_; |
| 181 gcm::GCMClient::Result unregistration_result_; | 182 gcm::GCMClient::Result unregistration_result_; |
| 182 instance_id::InstanceID::Result delete_id_result_; | 183 instance_id::InstanceID::Result delete_id_result_; |
| 183 bool app_handler_count_drop_to_zero_; | 184 bool app_handler_count_drop_to_zero_; |
| 184 | 185 |
| 185 DISALLOW_COPY_AND_ASSIGN(FakeExtensionGCMAppHandler); | 186 DISALLOW_COPY_AND_ASSIGN(FakeExtensionGCMAppHandler); |
| 186 }; | 187 }; |
| 187 | 188 |
| 188 class ExtensionGCMAppHandlerTest : public testing::Test { | 189 class ExtensionGCMAppHandlerTest : public testing::Test { |
| 189 public: | 190 public: |
| 190 static KeyedService* BuildGCMProfileService( | 191 static scoped_ptr<KeyedService> BuildGCMProfileService( |
| 191 content::BrowserContext* context) { | 192 content::BrowserContext* context) { |
| 192 return new gcm::GCMProfileService( | 193 return make_scoped_ptr(new gcm::GCMProfileService( |
| 193 Profile::FromBrowserContext(context), | 194 Profile::FromBrowserContext(context), |
| 194 scoped_ptr<gcm::GCMClientFactory>(new gcm::FakeGCMClientFactory( | 195 scoped_ptr<gcm::GCMClientFactory>(new gcm::FakeGCMClientFactory( |
| 195 content::BrowserThread::GetMessageLoopProxyForThread( | 196 content::BrowserThread::GetMessageLoopProxyForThread( |
| 196 content::BrowserThread::UI), | 197 content::BrowserThread::UI), |
| 197 content::BrowserThread::GetMessageLoopProxyForThread( | 198 content::BrowserThread::GetMessageLoopProxyForThread( |
| 198 content::BrowserThread::IO)))); | 199 content::BrowserThread::IO))))); |
| 199 } | 200 } |
| 200 | 201 |
| 201 ExtensionGCMAppHandlerTest() | 202 ExtensionGCMAppHandlerTest() |
| 202 : extension_service_(NULL), | 203 : extension_service_(NULL), |
| 203 registration_result_(gcm::GCMClient::UNKNOWN_ERROR), | 204 registration_result_(gcm::GCMClient::UNKNOWN_ERROR), |
| 204 unregistration_result_(gcm::GCMClient::UNKNOWN_ERROR) { | 205 unregistration_result_(gcm::GCMClient::UNKNOWN_ERROR) { |
| 205 } | 206 } |
| 206 | 207 |
| 207 ~ExtensionGCMAppHandlerTest() override {} | 208 ~ExtensionGCMAppHandlerTest() override {} |
| 208 | 209 |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 | 465 |
| 465 // App handler is removed when the extension is updated to the version that | 466 // App handler is removed when the extension is updated to the version that |
| 466 // has GCM permission removed. | 467 // has GCM permission removed. |
| 467 UpdateExtension(extension.get(), "good2.crx"); | 468 UpdateExtension(extension.get(), "good2.crx"); |
| 468 waiter()->PumpUILoop(); | 469 waiter()->PumpUILoop(); |
| 469 EXPECT_TRUE(gcm_app_handler()->app_handler_count_drop_to_zero()); | 470 EXPECT_TRUE(gcm_app_handler()->app_handler_count_drop_to_zero()); |
| 470 EXPECT_FALSE(HasAppHandlers(extension->id())); | 471 EXPECT_FALSE(HasAppHandlers(extension->id())); |
| 471 } | 472 } |
| 472 | 473 |
| 473 } // namespace extensions | 474 } // namespace extensions |
| OLD | NEW |