Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / services / gcm / fake_gcm_profile_service.h
blob58ba184ceefdb073f4d396b2f84b4c07dda2a9f8
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_SERVICES_GCM_FAKE_GCM_PROFILE_SERVICE_H_
6 #define CHROME_BROWSER_SERVICES_GCM_FAKE_GCM_PROFILE_SERVICE_H_
8 #include <list>
9 #include <vector>
11 #include "chrome/browser/services/gcm/gcm_profile_service.h"
12 #include "components/gcm_driver/gcm_driver.h"
14 namespace content {
15 class BrowserContext;
16 } // namespace content
18 namespace gcm {
20 // Acts as a bridge between GCM API and GCMClient layer for testing purposes.
21 class FakeGCMProfileService : public GCMProfileService {
22 public:
23 typedef base::Callback<void(const std::string&)> UnregisterCallback;
25 // Helper function to be used with
26 // KeyedService::SetTestingFactory().
27 static KeyedService* Build(content::BrowserContext* context);
29 explicit FakeGCMProfileService(Profile* profile);
30 ~FakeGCMProfileService() override;
32 void RegisterFinished(const std::string& app_id,
33 const std::vector<std::string>& sender_ids);
34 void UnregisterFinished(const std::string& app_id);
35 void SendFinished(const std::string& app_id,
36 const std::string& receiver_id,
37 const GCMClient::OutgoingMessage& message);
39 void AddExpectedUnregisterResponse(GCMClient::Result result);
41 void SetUnregisterCallback(const UnregisterCallback& callback);
43 const GCMClient::OutgoingMessage& last_sent_message() const {
44 return last_sent_message_;
47 const std::string& last_receiver_id() const {
48 return last_receiver_id_;
51 const std::string& last_registered_app_id() const {
52 return last_registered_app_id_;
55 const std::vector<std::string>& last_registered_sender_ids() const {
56 return last_registered_sender_ids_;
59 void set_collect(bool collect) {
60 collect_ = collect;
63 private:
64 // Indicates whether the service will collect paramters of the calls for
65 // furter verification in tests.
66 bool collect_;
67 // Used to give each registration a unique registration id. Does not decrease
68 // when unregister is called.
69 int registration_count_;
70 std::string last_registered_app_id_;
71 std::vector<std::string> last_registered_sender_ids_;
72 std::list<GCMClient::Result> unregister_responses_;
73 GCMClient::OutgoingMessage last_sent_message_;
74 std::string last_receiver_id_;
75 UnregisterCallback unregister_callback_;
77 DISALLOW_COPY_AND_ASSIGN(FakeGCMProfileService);
80 } // namespace gcm
82 #endif // CHROME_BROWSER_SERVICES_GCM_FAKE_GCM_PROFILE_SERVICE_H_