Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef COMPONENTS_ARC_TEST_FAKE_INTENT_HELPER_INSTANCE_H_ | 5 #ifndef COMPONENTS_ARC_TEST_FAKE_INTENT_HELPER_INSTANCE_H_ |
| 6 #define COMPONENTS_ARC_TEST_FAKE_INTENT_HELPER_INSTANCE_H_ | 6 #define COMPONENTS_ARC_TEST_FAKE_INTENT_HELPER_INSTANCE_H_ |
| 7 | 7 |
| 8 #include <map> | |
| 8 #include <string> | 9 #include <string> |
| 9 #include <vector> | 10 #include <vector> |
| 10 | 11 |
| 11 #include "base/callback.h" | 12 #include "base/callback.h" |
| 12 #include "components/arc/common/intent_helper.mojom.h" | 13 #include "components/arc/common/intent_helper.mojom.h" |
| 13 | 14 |
| 14 namespace arc { | 15 namespace arc { |
| 15 | 16 |
| 16 class FakeIntentHelperInstance : public mojom::IntentHelperInstance { | 17 class FakeIntentHelperInstance : public mojom::IntentHelperInstance { |
| 17 public: | 18 public: |
| 18 FakeIntentHelperInstance(); | 19 FakeIntentHelperInstance(); |
| 19 | 20 |
| 20 class Broadcast { | 21 class Broadcast { |
| 21 public: | 22 public: |
| 22 Broadcast(const std::string& action, | 23 Broadcast(const std::string& action, |
| 23 const std::string& package_name, | 24 const std::string& package_name, |
| 24 const std::string& cls, | 25 const std::string& cls, |
| 25 const std::string& extras); | 26 const std::string& extras); |
| 26 | 27 |
| 27 ~Broadcast(); | 28 ~Broadcast(); |
| 28 | 29 |
| 29 Broadcast(const Broadcast& broadcast); | 30 Broadcast(const Broadcast& broadcast); |
| 30 | 31 |
| 31 std::string action; | 32 std::string action; |
| 32 std::string package_name; | 33 std::string package_name; |
| 33 std::string cls; | 34 std::string cls; |
| 34 std::string extras; | 35 std::string extras; |
| 35 }; | 36 }; |
| 36 | 37 |
| 38 // Parameters passed to HandleIntent(). | |
| 39 struct HandledIntent { | |
| 40 HandledIntent(mojom::IntentInfoPtr intent, | |
|
Luis Héctor Chávez
2016/12/16 16:57:44
You can even get rid of all this boilerplate if yo
Daniel Erat
2016/12/16 17:05:37
hmm. this was the first thing i tried in this chan
Luis Héctor Chávez
2016/12/16 17:16:18
argh, foiled again by the fact that we use multipl
hidehiko
2016/12/16 17:20:12
Oh, you hit https://www.chromium.org/developers/co
| |
| 41 mojom::ActivityNamePtr activity); | |
| 42 HandledIntent(HandledIntent&& other); | |
| 43 HandledIntent& operator=(HandledIntent&& other); | |
| 44 ~HandledIntent(); | |
| 45 | |
| 46 mojom::IntentInfoPtr intent; | |
| 47 mojom::ActivityNamePtr activity; | |
| 48 }; | |
| 49 | |
| 37 void clear_broadcasts() { broadcasts_.clear(); } | 50 void clear_broadcasts() { broadcasts_.clear(); } |
| 51 void clear_handled_intents() { handled_intents_.clear(); } | |
| 38 | 52 |
| 39 const std::vector<Broadcast>& broadcasts() const { return broadcasts_; } | 53 const std::vector<Broadcast>& broadcasts() const { return broadcasts_; } |
| 54 const std::vector<HandledIntent>& handled_intents() const { | |
| 55 return handled_intents_; | |
| 56 } | |
| 57 | |
| 58 // Sets a list of intent handlers to be returned in response to | |
| 59 // RequestIntentHandlerList() calls with intents containing |action|. | |
| 60 void SetIntentHandlers( | |
| 61 const std::string& action, | |
| 62 std::vector<mojom::IntentHandlerInfoPtr> handlers); | |
| 40 | 63 |
| 41 // mojom::IntentHelperInstance: | 64 // mojom::IntentHelperInstance: |
| 42 ~FakeIntentHelperInstance() override; | 65 ~FakeIntentHelperInstance() override; |
| 43 | 66 |
| 44 void AddPreferredPackage(const std::string& package_name) override; | 67 void AddPreferredPackage(const std::string& package_name) override; |
| 45 | 68 |
| 46 void GetFileSizeDeprecated( | 69 void GetFileSizeDeprecated( |
| 47 const std::string& url, | 70 const std::string& url, |
| 48 const GetFileSizeDeprecatedCallback& callback) override; | 71 const GetFileSizeDeprecatedCallback& callback) override; |
| 49 | 72 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 const RequestUrlListHandlerListCallback& callback) override; | 104 const RequestUrlListHandlerListCallback& callback) override; |
| 82 | 105 |
| 83 void SendBroadcast(const std::string& action, | 106 void SendBroadcast(const std::string& action, |
| 84 const std::string& package_name, | 107 const std::string& package_name, |
| 85 const std::string& cls, | 108 const std::string& cls, |
| 86 const std::string& extras) override; | 109 const std::string& extras) override; |
| 87 | 110 |
| 88 private: | 111 private: |
| 89 std::vector<Broadcast> broadcasts_; | 112 std::vector<Broadcast> broadcasts_; |
| 90 | 113 |
| 114 // Information about calls to HandleIntent(). | |
| 115 std::vector<HandledIntent> handled_intents_; | |
| 116 | |
| 117 // Map from action names to intent handlers to be returned by | |
| 118 // RequestIntentHandlerList(). | |
| 119 std::map<std::string, std::vector<mojom::IntentHandlerInfoPtr>> | |
| 120 intent_handlers_; | |
| 121 | |
| 91 DISALLOW_COPY_AND_ASSIGN(FakeIntentHelperInstance); | 122 DISALLOW_COPY_AND_ASSIGN(FakeIntentHelperInstance); |
| 92 }; | 123 }; |
| 93 | 124 |
| 94 } // namespace arc | 125 } // namespace arc |
| 95 | 126 |
| 96 #endif // COMPONENTS_ARC_TEST_FAKE_INTENT_HELPER_INSTANCE_H_ | 127 #endif // COMPONENTS_ARC_TEST_FAKE_INTENT_HELPER_INSTANCE_H_ |
| OLD | NEW |