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

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: 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
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 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 // Sign-in is needed for registration. 371 // Sign-in is needed for registration.
371 SignIn(kTestingUsername); 372 SignIn(kTestingUsername);
372 373
373 // Kick off registration. 374 // Kick off registration.
374 std::vector<std::string> sender_ids; 375 std::vector<std::string> sender_ids;
375 sender_ids.push_back("sender1"); 376 sender_ids.push_back("sender1");
376 Register(extension->id(), sender_ids); 377 Register(extension->id(), sender_ids);
377 waiter()->WaitUntilCompleted(); 378 waiter()->WaitUntilCompleted();
378 EXPECT_EQ(gcm::GCMClient::SUCCESS, registration_result()); 379 EXPECT_EQ(gcm::GCMClient::SUCCESS, registration_result());
379 380
381 // Add another app handler in order to prevent the GCM service from being
382 // stopped when the extension is uninstalled. This is needed because otherwise
383 // we are not able to receive the unregistration result.
384 GetGCMDriver()->AddAppHandler("Foo", gcm_app_handler());
385
380 // Unregistration should be triggered when the extension is uninstalled. 386 // Unregistration should be triggered when the extension is uninstalled.
381 UninstallExtension(extension); 387 UninstallExtension(extension);
382 waiter()->WaitUntilCompleted(); 388 waiter()->WaitUntilCompleted();
383 EXPECT_EQ(gcm::GCMClient::SUCCESS, 389 EXPECT_EQ(gcm::GCMClient::SUCCESS,
384 gcm_app_handler()->unregistration_result()); 390 gcm_app_handler()->unregistration_result());
391
392 // Clean up.
393 GetGCMDriver()->RemoveAppHandler("Foo");
385 } 394 }
386 395
387 } // namespace extensions 396 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/services/gcm/fake_gcm_app_handler.h » ('j') | chrome/browser/services/gcm/gcm_driver.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698