blob: adfe45e6b2bb4a102bed046a31f5d36ecd7cc0b5 [file] [log] [blame]
[email protected]3ecb2b582014-05-23 00:25:391// Copyright 2014 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.
4
[email protected]8d41e5a2014-05-28 03:18:495#ifndef COMPONENTS_GCM_DRIVER_FAKE_GCM_APP_HANDLER_H_
6#define COMPONENTS_GCM_DRIVER_FAKE_GCM_APP_HANDLER_H_
[email protected]3ecb2b582014-05-23 00:25:397
dchenga77e28eb2016-04-21 21:34:378#include <memory>
9
[email protected]3ecb2b582014-05-23 00:25:3910#include "base/compiler_specific.h"
avi26062922015-12-26 00:14:1811#include "base/macros.h"
[email protected]3ecb2b582014-05-23 00:25:3912#include "components/gcm_driver/gcm_app_handler.h"
13
14namespace base {
15class RunLoop;
16}
17
18namespace gcm {
19
20class FakeGCMAppHandler : public GCMAppHandler {
21 public:
22 enum Event {
23 NO_EVENT,
24 MESSAGE_EVENT,
25 MESSAGES_DELETED_EVENT,
26 SEND_ERROR_EVENT
27 };
28
29 FakeGCMAppHandler();
dcheng00ea022b2014-10-21 11:24:5630 ~FakeGCMAppHandler() override;
[email protected]3ecb2b582014-05-23 00:25:3931
32 const Event& received_event() const { return received_event_; }
33 const std::string& app_id() const { return app_id_; }
[email protected]292af2b22014-08-06 19:42:4534 const std::string& acked_message_id() const { return acked_message_id_; }
mvanouwerkerkf8633deb2015-07-13 11:04:0635 const IncomingMessage& message() const { return message_; }
[email protected]3ecb2b582014-05-23 00:25:3936 const GCMClient::SendErrorDetails& send_error_details() const {
37 return send_error_details_;
38 }
39
40 void WaitForNotification();
41
[email protected]fc6078a2014-06-14 08:28:4342 // GCMAppHandler implementation.
dcheng00ea022b2014-10-21 11:24:5643 void ShutdownHandler() override;
johnme93ec7932016-11-17 14:26:5844 void OnStoreReset() override;
dcheng00ea022b2014-10-21 11:24:5645 void OnMessage(const std::string& app_id,
mvanouwerkerkf8633deb2015-07-13 11:04:0646 const IncomingMessage& message) override;
dcheng00ea022b2014-10-21 11:24:5647 void OnMessagesDeleted(const std::string& app_id) override;
48 void OnSendError(
[email protected]3ecb2b582014-05-23 00:25:3949 const std::string& app_id,
mostynbfe59f482014-10-06 15:04:4650 const GCMClient::SendErrorDetails& send_error_details) override;
dcheng00ea022b2014-10-21 11:24:5651 void OnSendAcknowledged(const std::string& app_id,
52 const std::string& message_id) override;
[email protected]3ecb2b582014-05-23 00:25:3953
54 private:
55 void ClearResults();
56
dchenga77e28eb2016-04-21 21:34:3757 std::unique_ptr<base::RunLoop> run_loop_;
[email protected]3ecb2b582014-05-23 00:25:3958
59 Event received_event_;
60 std::string app_id_;
[email protected]292af2b22014-08-06 19:42:4561 std::string acked_message_id_;
mvanouwerkerkf8633deb2015-07-13 11:04:0662 IncomingMessage message_;
[email protected]3ecb2b582014-05-23 00:25:3963 GCMClient::SendErrorDetails send_error_details_;
64
65 DISALLOW_COPY_AND_ASSIGN(FakeGCMAppHandler);
66};
67
68} // namespace gcm
69
[email protected]8d41e5a2014-05-28 03:18:4970#endif // COMPONENTS_GCM_DRIVER_FAKE_GCM_APP_HANDLER_H_