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

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

Issue 296053011: Start and stop the GCM service on demand (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync Created 6 years, 7 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/services/gcm/fake_gcm_app_handler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/location.h" 13 #include "base/location.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
17 #include "base/run_loop.h" 17 #include "base/run_loop.h"
18 #include "base/values.h" 18 #include "base/values.h"
19 #include "chrome/browser/extensions/extension_service.h" 19 #include "chrome/browser/extensions/extension_service.h"
20 #include "chrome/browser/extensions/test_extension_service.h" 20 #include "chrome/browser/extensions/test_extension_service.h"
21 #include "chrome/browser/extensions/test_extension_system.h" 21 #include "chrome/browser/extensions/test_extension_system.h"
22 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
23 #include "chrome/browser/services/gcm/fake_gcm_app_handler.h"
23 #include "chrome/browser/services/gcm/fake_gcm_client.h" 24 #include "chrome/browser/services/gcm/fake_gcm_client.h"
24 #include "chrome/browser/services/gcm/fake_gcm_client_factory.h" 25 #include "chrome/browser/services/gcm/fake_gcm_client_factory.h"
25 #include "chrome/browser/services/gcm/fake_signin_manager.h" 26 #include "chrome/browser/services/gcm/fake_signin_manager.h"
26 #include "chrome/browser/services/gcm/gcm_driver.h" 27 #include "chrome/browser/services/gcm/gcm_driver.h"
27 #include "chrome/browser/services/gcm/gcm_profile_service.h" 28 #include "chrome/browser/services/gcm/gcm_profile_service.h"
28 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" 29 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h"
29 #include "chrome/browser/signin/signin_manager_factory.h" 30 #include "chrome/browser/signin/signin_manager_factory.h"
30 #include "chrome/common/pref_names.h" 31 #include "chrome/common/pref_names.h"
31 #include "chrome/test/base/testing_profile.h" 32 #include "chrome/test/base/testing_profile.h"
32 #include "components/gcm_driver/gcm_client_factory.h" 33 #include "components/gcm_driver/gcm_client_factory.h"
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 // Sign-in is needed for registration. 375 // Sign-in is needed for registration.
375 SignIn(kTestingUsername); 376 SignIn(kTestingUsername);
376 377
377 // Kick off registration. 378 // Kick off registration.
378 std::vector<std::string> sender_ids; 379 std::vector<std::string> sender_ids;
379 sender_ids.push_back("sender1"); 380 sender_ids.push_back("sender1");
380 Register(extension->id(), sender_ids); 381 Register(extension->id(), sender_ids);
381 waiter()->WaitUntilCompleted(); 382 waiter()->WaitUntilCompleted();
382 EXPECT_EQ(gcm::GCMClient::SUCCESS, registration_result()); 383 EXPECT_EQ(gcm::GCMClient::SUCCESS, registration_result());
383 384
385 // Add another app handler in order to prevent the GCM service from being
386 // stopped when the extension is uninstalled. This is needed because otherwise
387 // we are not able to receive the unregistration result.
388 GetGCMDriver()->AddAppHandler("Foo", gcm_app_handler());
389
384 // Unregistration should be triggered when the extension is uninstalled. 390 // Unregistration should be triggered when the extension is uninstalled.
385 UninstallExtension(extension); 391 UninstallExtension(extension);
386 waiter()->WaitUntilCompleted(); 392 waiter()->WaitUntilCompleted();
387 EXPECT_EQ(gcm::GCMClient::SUCCESS, 393 EXPECT_EQ(gcm::GCMClient::SUCCESS,
388 gcm_app_handler()->unregistration_result()); 394 gcm_app_handler()->unregistration_result());
395
396 // Clean up.
397 GetGCMDriver()->RemoveAppHandler("Foo");
389 } 398 }
390 399
391 } // namespace extensions 400 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/services/gcm/fake_gcm_app_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698