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

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

Issue 2579193003: arc: Implement more methods in FakeIntentHelperInstance. (Closed)
Patch Set: get std::move-based approach working 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..e3e27d27cdcd5ed66d2256f2193533f1da94df79 100644
--- a/components/arc/test/fake_intent_helper_instance.cc
+++ b/components/arc/test/fake_intent_helper_instance.cc
@@ -4,6 +4,11 @@
#include "components/arc/test/fake_intent_helper_instance.h"
+#include <utility>
+
+#include "base/bind.h"
+#include "base/threading/thread_task_runner_handle.h"
+
namespace arc {
FakeIntentHelperInstance::FakeIntentHelperInstance() {}
@@ -22,6 +27,26 @@ FakeIntentHelperInstance::Broadcast::Broadcast(const Broadcast& broadcast)
FakeIntentHelperInstance::Broadcast::~Broadcast() {}
+FakeIntentHelperInstance::HandledIntent::HandledIntent(
+ mojom::IntentInfoPtr intent,
+ mojom::ActivityNamePtr activity)
+ : intent(std::move(intent)), activity(std::move(activity)) {}
+
+FakeIntentHelperInstance::HandledIntent::HandledIntent(HandledIntent&& other)
+ : HandledIntent(std::move(other.intent), std::move(other.activity)) {}
+
+FakeIntentHelperInstance::HandledIntent&
+FakeIntentHelperInstance::HandledIntent::operator=(HandledIntent&& other) =
+ default;
+
+FakeIntentHelperInstance::HandledIntent::~HandledIntent() = default;
+
+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 +57,9 @@ void FakeIntentHelperInstance::GetFileSizeDeprecated(
const GetFileSizeDeprecatedCallback& callback) {}
void FakeIntentHelperInstance::HandleIntent(mojom::IntentInfoPtr intent,
- mojom::ActivityNamePtr activity) {}
+ mojom::ActivityNamePtr activity) {
+ handled_intents_.emplace_back(std::move(intent), std::move(activity));
+}
void FakeIntentHelperInstance::HandleUrl(const std::string& url,
const std::string& package_name) {}
@@ -55,7 +82,18 @@ 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);
Luis Héctor Chávez 2016/12/16 16:57:44 nit: const auto?
Daniel Erat 2016/12/16 17:05:37 thanks, forgot to update this once the iterator wa
+ if (it != intent_handlers_.end()) {
+ handlers.reserve(it->second.size());
+ for (const auto& handler : it->second) {
+ handlers.emplace_back(handler.Clone());
+ }
+ }
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
Luis Héctor Chávez 2016/12/16 16:57:44 Can you add a brief comment as to why you need to
Daniel Erat 2016/12/16 17:05:37 Done.
+ FROM_HERE, base::Bind(callback, base::Passed(std::move(handlers))));
+}
void FakeIntentHelperInstance::RequestUrlHandlerList(
const std::string& url,

Powered by Google App Engine
This is Rietveld 408576698