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

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 UT errors as per comments 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 scoped_refptr<base::SequencedTaskRunner> ui_thread =
200 content::BrowserThread::GetMessageLoopProxyForThread(
201 content::BrowserThread::UI);
202 scoped_refptr<base::SequencedTaskRunner> io_thread =
203 content::BrowserThread::GetMessageLoopProxyForThread(
204 content::BrowserThread::IO);
205 base::SequencedWorkerPool* worker_pool =
206 content::BrowserThread::GetBlockingPool();
207 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner(
208 worker_pool->GetSequencedTaskRunnerWithShutdownBehavior(
209 worker_pool->GetSequenceToken(),
210 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN));
193 return make_scoped_ptr(new gcm::GCMProfileService( 211 return make_scoped_ptr(new gcm::GCMProfileService(
194 Profile::FromBrowserContext(context), 212 profile->GetPrefs(), profile->GetPath(), profile->GetRequestContext(),
195 scoped_ptr<gcm::GCMClientFactory>(new gcm::FakeGCMClientFactory( 213 chrome::GetChannel(),
196 content::BrowserThread::GetMessageLoopProxyForThread( 214 scoped_ptr<ProfileIdentityProvider>(new ProfileIdentityProvider(
197 content::BrowserThread::UI), 215 SigninManagerFactory::GetForProfile(profile),
198 content::BrowserThread::GetMessageLoopProxyForThread( 216 ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
199 content::BrowserThread::IO))))); 217 LoginUIServiceFactory::GetShowLoginPopupCallbackForProfile(
218 profile))),
219 make_scoped_ptr(new gcm::FakeGCMClientFactory(ui_thread, io_thread)),
220 ui_thread, io_thread, blocking_task_runner));
200 } 221 }
201 222
202 ExtensionGCMAppHandlerTest() 223 ExtensionGCMAppHandlerTest()
203 : extension_service_(NULL), 224 : extension_service_(NULL),
204 registration_result_(gcm::GCMClient::UNKNOWN_ERROR), 225 registration_result_(gcm::GCMClient::UNKNOWN_ERROR),
205 unregistration_result_(gcm::GCMClient::UNKNOWN_ERROR) { 226 unregistration_result_(gcm::GCMClient::UNKNOWN_ERROR) {
206 } 227 }
207 228
208 ~ExtensionGCMAppHandlerTest() override {} 229 ~ExtensionGCMAppHandlerTest() override {}
209 230
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 486
466 // App handler is removed when the extension is updated to the version that 487 // App handler is removed when the extension is updated to the version that
467 // has GCM permission removed. 488 // has GCM permission removed.
468 UpdateExtension(extension.get(), "good2.crx"); 489 UpdateExtension(extension.get(), "good2.crx");
469 waiter()->PumpUILoop(); 490 waiter()->PumpUILoop();
470 EXPECT_TRUE(gcm_app_handler()->app_handler_count_drop_to_zero()); 491 EXPECT_TRUE(gcm_app_handler()->app_handler_count_drop_to_zero());
471 EXPECT_FALSE(HasAppHandlers(extension->id())); 492 EXPECT_FALSE(HasAppHandlers(extension->id()));
472 } 493 }
473 494
474 } // namespace extensions 495 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698