Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(289)

Side by Side Diff: chrome/browser/extensions/extension_gcm_app_handler_unittest.cc

Issue 1425783002: Componentizing GcmProfileService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/memory/scoped_ptr.h"
19 #include "base/message_loop/message_loop.h" 19 #include "base/message_loop/message_loop.h"
20 #include "base/path_service.h" 20 #include "base/path_service.h"
21 #include "base/run_loop.h" 21 #include "base/run_loop.h"
22 #include "base/values.h" 22 #include "base/values.h"
23 #include "chrome/browser/chrome_notification_types.h" 23 #include "chrome/browser/chrome_notification_types.h"
24 #include "chrome/browser/extensions/api/gcm/gcm_api.h" 24 #include "chrome/browser/extensions/api/gcm/gcm_api.h"
25 #include "chrome/browser/extensions/extension_service.h" 25 #include "chrome/browser/extensions/extension_service.h"
26 #include "chrome/browser/extensions/test_extension_service.h" 26 #include "chrome/browser/extensions/test_extension_service.h"
27 #include "chrome/browser/extensions/test_extension_system.h" 27 #include "chrome/browser/extensions/test_extension_system.h"
28 #include "chrome/browser/profiles/profile.h" 28 #include "chrome/browser/profiles/profile.h"
29 #include "chrome/browser/services/gcm/gcm_profile_service.h"
30 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" 29 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h"
30 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
31 #include "chrome/browser/signin/signin_manager_factory.h"
32 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
33 #include "chrome/common/channel_info.h"
31 #include "chrome/common/chrome_paths.h" 34 #include "chrome/common/chrome_paths.h"
32 #include "chrome/test/base/testing_profile.h" 35 #include "chrome/test/base/testing_profile.h"
33 #include "components/gcm_driver/fake_gcm_app_handler.h" 36 #include "components/gcm_driver/fake_gcm_app_handler.h"
34 #include "components/gcm_driver/fake_gcm_client.h" 37 #include "components/gcm_driver/fake_gcm_client.h"
35 #include "components/gcm_driver/fake_gcm_client_factory.h" 38 #include "components/gcm_driver/fake_gcm_client_factory.h"
36 #include "components/gcm_driver/gcm_client_factory.h" 39 #include "components/gcm_driver/gcm_client_factory.h"
37 #include "components/gcm_driver/gcm_driver.h" 40 #include "components/gcm_driver/gcm_driver.h"
41 #include "components/gcm_driver/gcm_profile_service.h"
38 #include "components/keyed_service/core/keyed_service.h" 42 #include "components/keyed_service/core/keyed_service.h"
43 #include "components/signin/core/browser/signin_manager.h"
39 #include "content/public/browser/browser_context.h" 44 #include "content/public/browser/browser_context.h"
40 #include "content/public/browser/browser_thread.h" 45 #include "content/public/browser/browser_thread.h"
41 #include "content/public/test/test_browser_thread_bundle.h" 46 #include "content/public/test/test_browser_thread_bundle.h"
42 #include "content/public/test/test_utils.h" 47 #include "content/public/test/test_utils.h"
43 #include "extensions/browser/extension_system.h" 48 #include "extensions/browser/extension_system.h"
44 #include "extensions/browser/uninstall_reason.h" 49 #include "extensions/browser/uninstall_reason.h"
45 #include "extensions/common/extension.h" 50 #include "extensions/common/extension.h"
46 #include "extensions/common/manifest.h" 51 #include "extensions/common/manifest.h"
47 #include "extensions/common/manifest_constants.h" 52 #include "extensions/common/manifest_constants.h"
48 #include "extensions/common/permissions/api_permission.h" 53 #include "extensions/common/permissions/api_permission.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 instance_id::InstanceID::Result delete_id_result_; 188 instance_id::InstanceID::Result delete_id_result_;
184 bool app_handler_count_drop_to_zero_; 189 bool app_handler_count_drop_to_zero_;
185 190
186 DISALLOW_COPY_AND_ASSIGN(FakeExtensionGCMAppHandler); 191 DISALLOW_COPY_AND_ASSIGN(FakeExtensionGCMAppHandler);
187 }; 192 };
188 193
189 class ExtensionGCMAppHandlerTest : public testing::Test { 194 class ExtensionGCMAppHandlerTest : public testing::Test {
190 public: 195 public:
191 static scoped_ptr<KeyedService> BuildGCMProfileService( 196 static scoped_ptr<KeyedService> BuildGCMProfileService(
192 content::BrowserContext* context) { 197 content::BrowserContext* context) {
198 Profile* profile = Profile::FromBrowserContext(context);
199 base::SequencedWorkerPool* worker_pool =
200 content::BrowserThread::GetBlockingPool();
201 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner(
202 worker_pool->GetSequencedTaskRunnerWithShutdownBehavior(
203 worker_pool->GetSequenceToken(),
204 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN));
193 return make_scoped_ptr(new gcm::GCMProfileService( 205 return make_scoped_ptr(new gcm::GCMProfileService(
194 Profile::FromBrowserContext(context), 206 profile->GetPrefs(), profile->GetPath(), profile->GetRequestContext(),
207 chrome::GetChannel(), SigninManagerFactory::GetForProfile(profile),
208 ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
209 LoginUIServiceFactory::GetShowLoginPopupCallbackForProfile(profile),
195 scoped_ptr<gcm::GCMClientFactory>(new gcm::FakeGCMClientFactory( 210 scoped_ptr<gcm::GCMClientFactory>(new gcm::FakeGCMClientFactory(
196 content::BrowserThread::GetMessageLoopProxyForThread( 211 content::BrowserThread::GetMessageLoopProxyForThread(
197 content::BrowserThread::UI), 212 content::BrowserThread::UI),
198 content::BrowserThread::GetMessageLoopProxyForThread( 213 content::BrowserThread::GetMessageLoopProxyForThread(
199 content::BrowserThread::IO))))); 214 content::BrowserThread::IO))),
215 content::BrowserThread::GetMessageLoopProxyForThread(
216 content::BrowserThread::UI),
217 content::BrowserThread::GetMessageLoopProxyForThread(
218 content::BrowserThread::IO),
219 blocking_task_runner));
200 } 220 }
201 221
202 ExtensionGCMAppHandlerTest() 222 ExtensionGCMAppHandlerTest()
203 : extension_service_(NULL), 223 : extension_service_(NULL),
204 registration_result_(gcm::GCMClient::UNKNOWN_ERROR), 224 registration_result_(gcm::GCMClient::UNKNOWN_ERROR),
205 unregistration_result_(gcm::GCMClient::UNKNOWN_ERROR) { 225 unregistration_result_(gcm::GCMClient::UNKNOWN_ERROR) {
206 } 226 }
207 227
208 ~ExtensionGCMAppHandlerTest() override {} 228 ~ExtensionGCMAppHandlerTest() override {}
209 229
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 485
466 // App handler is removed when the extension is updated to the version that 486 // App handler is removed when the extension is updated to the version that
467 // has GCM permission removed. 487 // has GCM permission removed.
468 UpdateExtension(extension.get(), "good2.crx"); 488 UpdateExtension(extension.get(), "good2.crx");
469 waiter()->PumpUILoop(); 489 waiter()->PumpUILoop();
470 EXPECT_TRUE(gcm_app_handler()->app_handler_count_drop_to_zero()); 490 EXPECT_TRUE(gcm_app_handler()->app_handler_count_drop_to_zero());
471 EXPECT_FALSE(HasAppHandlers(extension->id())); 491 EXPECT_FALSE(HasAppHandlers(extension->id()));
472 } 492 }
473 493
474 } // namespace extensions 494 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698