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

Unified Diff: components/arc/test/fake_intent_helper_instance.cc

Issue 2579193003: arc: Implement more methods in FakeIntentHelperInstance. (Closed)
Patch Set: Created 4 years 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 side-by-side diff with in-line comments
Download patch
Index: components/arc/test/fake_intent_helper_instance.cc
diff --git a/components/arc/test/fake_intent_helper_instance.cc b/components/arc/test/fake_intent_helper_instance.cc
index d57d8e3a2cf3f16d7c3187fa46ee8069c4e46e23..8c0c6ac5f4d9965c74f1854294191361ee2cba1e 100644
--- a/components/arc/test/fake_intent_helper_instance.cc
+++ b/components/arc/test/fake_intent_helper_instance.cc
@@ -4,10 +4,34 @@
#include "components/arc/test/fake_intent_helper_instance.h"
+#include <utility>
+
+#include "base/bind.h"
+#include "base/threading/sequenced_task_runner_handle.h"
+
namespace arc {
FakeIntentHelperInstance::FakeIntentHelperInstance() {}
+FakeIntentHelperInstance::HandledIntent::HandledIntent(
+ const mojom::IntentInfoPtr& intent,
+ const mojom::ActivityNamePtr& activity)
+ : action(intent->action),
+ categories(intent->categories ? *(intent->categories)
+ : std::vector<std::string>()),
Daniel Erat 2016/12/16 02:29:03 this is also a bit ugly. all of these fields are b
+ data(intent->data ? *(intent->data) : std::string()),
+ type(intent->type ? *(intent->type) : std::string()),
+ clip_data_uri(intent->clip_data_uri ? *(intent->clip_data_uri)
+ : std::string()),
+ package(activity->package_name),
+ activity(activity->activity_name ? *(activity->activity_name)
+ : std::string()) {}
+
+FakeIntentHelperInstance::HandledIntent::HandledIntent(
+ const HandledIntent& other) = default;
+
+FakeIntentHelperInstance::HandledIntent::~HandledIntent() = default;
+
FakeIntentHelperInstance::Broadcast::Broadcast(const std::string& action,
const std::string& package_name,
const std::string& cls,
@@ -22,6 +46,12 @@ FakeIntentHelperInstance::Broadcast::Broadcast(const Broadcast& broadcast)
FakeIntentHelperInstance::Broadcast::~Broadcast() {}
+void FakeIntentHelperInstance::SetIntentHandlers(
+ const std::string& action,
+ std::vector<mojom::IntentHandlerInfoPtr> handlers) {
+ intent_handlers_[action] = std::move(handlers);
+}
+
FakeIntentHelperInstance::~FakeIntentHelperInstance() {}
void FakeIntentHelperInstance::AddPreferredPackage(
@@ -32,7 +62,9 @@ void FakeIntentHelperInstance::GetFileSizeDeprecated(
const GetFileSizeDeprecatedCallback& callback) {}
void FakeIntentHelperInstance::HandleIntent(mojom::IntentInfoPtr intent,
- mojom::ActivityNamePtr activity) {}
+ mojom::ActivityNamePtr activity) {
+ handled_intents_.emplace_back(HandledIntent(intent, activity));
hidehiko 2016/12/16 04:27:12 emplace_back(intent, activity); Could you take a
Daniel Erat 2016/12/16 05:41:04 thanks; done.
+}
void FakeIntentHelperInstance::HandleUrl(const std::string& url,
const std::string& package_name) {}
@@ -55,7 +87,16 @@ void FakeIntentHelperInstance::RequestActivityIcons(
void FakeIntentHelperInstance::RequestIntentHandlerList(
mojom::IntentInfoPtr intent,
- const RequestIntentHandlerListCallback& callback) {}
+ const RequestIntentHandlerListCallback& callback) {
+ std::vector<mojom::IntentHandlerInfoPtr> handlers;
+ auto it = intent_handlers_.find(intent->action);
+ if (it != intent_handlers_.end()) {
+ handlers = std::move(it->second);
+ intent_handlers_.erase(it);
+ }
+ base::SequencedTaskRunnerHandle::Get()->PostTask(
hidehiko 2016/12/16 04:27:12 In ARC code, ThreadTaskRunnerHandle is used. How a
Daniel Erat 2016/12/16 05:41:04 sure. ThreadTaskRunnerHandle has a comment recomme
+ FROM_HERE, base::Bind(callback, base::Passed(std::move(handlers))));
Daniel Erat 2016/12/16 02:29:03 base::Passed(std::move()) looks very wrong to me,
hidehiko 2016/12/16 04:27:12 rvalue is actually needed for base::Passed, so it
Daniel Erat 2016/12/16 05:41:04 Acknowledged.
+}
void FakeIntentHelperInstance::RequestUrlHandlerList(
const std::string& url,

Powered by Google App Engine
This is Rietveld 408576698