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

Side by Side 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 unified diff | Download patch
OLDNEW
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 #include "components/arc/test/fake_intent_helper_instance.h" 5 #include "components/arc/test/fake_intent_helper_instance.h"
6 6
7 #include <utility>
8
9 #include "base/bind.h"
10 #include "base/threading/sequenced_task_runner_handle.h"
11
7 namespace arc { 12 namespace arc {
8 13
9 FakeIntentHelperInstance::FakeIntentHelperInstance() {} 14 FakeIntentHelperInstance::FakeIntentHelperInstance() {}
10 15
16 FakeIntentHelperInstance::HandledIntent::HandledIntent(
17 const mojom::IntentInfoPtr& intent,
18 const mojom::ActivityNamePtr& activity)
19 : action(intent->action),
20 categories(intent->categories ? *(intent->categories)
21 : std::vector<std::string>()),
Daniel Erat 2016/12/16 02:29:03 this is also a bit ugly. all of these fields are b
22 data(intent->data ? *(intent->data) : std::string()),
23 type(intent->type ? *(intent->type) : std::string()),
24 clip_data_uri(intent->clip_data_uri ? *(intent->clip_data_uri)
25 : std::string()),
26 package(activity->package_name),
27 activity(activity->activity_name ? *(activity->activity_name)
28 : std::string()) {}
29
30 FakeIntentHelperInstance::HandledIntent::HandledIntent(
31 const HandledIntent& other) = default;
32
33 FakeIntentHelperInstance::HandledIntent::~HandledIntent() = default;
34
11 FakeIntentHelperInstance::Broadcast::Broadcast(const std::string& action, 35 FakeIntentHelperInstance::Broadcast::Broadcast(const std::string& action,
12 const std::string& package_name, 36 const std::string& package_name,
13 const std::string& cls, 37 const std::string& cls,
14 const std::string& extras) 38 const std::string& extras)
15 : action(action), package_name(package_name), cls(cls), extras(extras) {} 39 : action(action), package_name(package_name), cls(cls), extras(extras) {}
16 40
17 FakeIntentHelperInstance::Broadcast::Broadcast(const Broadcast& broadcast) 41 FakeIntentHelperInstance::Broadcast::Broadcast(const Broadcast& broadcast)
18 : action(broadcast.action), 42 : action(broadcast.action),
19 package_name(broadcast.package_name), 43 package_name(broadcast.package_name),
20 cls(broadcast.cls), 44 cls(broadcast.cls),
21 extras(broadcast.extras) {} 45 extras(broadcast.extras) {}
22 46
23 FakeIntentHelperInstance::Broadcast::~Broadcast() {} 47 FakeIntentHelperInstance::Broadcast::~Broadcast() {}
24 48
49 void FakeIntentHelperInstance::SetIntentHandlers(
50 const std::string& action,
51 std::vector<mojom::IntentHandlerInfoPtr> handlers) {
52 intent_handlers_[action] = std::move(handlers);
53 }
54
25 FakeIntentHelperInstance::~FakeIntentHelperInstance() {} 55 FakeIntentHelperInstance::~FakeIntentHelperInstance() {}
26 56
27 void FakeIntentHelperInstance::AddPreferredPackage( 57 void FakeIntentHelperInstance::AddPreferredPackage(
28 const std::string& package_name) {} 58 const std::string& package_name) {}
29 59
30 void FakeIntentHelperInstance::GetFileSizeDeprecated( 60 void FakeIntentHelperInstance::GetFileSizeDeprecated(
31 const std::string& url, 61 const std::string& url,
32 const GetFileSizeDeprecatedCallback& callback) {} 62 const GetFileSizeDeprecatedCallback& callback) {}
33 63
34 void FakeIntentHelperInstance::HandleIntent(mojom::IntentInfoPtr intent, 64 void FakeIntentHelperInstance::HandleIntent(mojom::IntentInfoPtr intent,
35 mojom::ActivityNamePtr activity) {} 65 mojom::ActivityNamePtr activity) {
66 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.
67 }
36 68
37 void FakeIntentHelperInstance::HandleUrl(const std::string& url, 69 void FakeIntentHelperInstance::HandleUrl(const std::string& url,
38 const std::string& package_name) {} 70 const std::string& package_name) {}
39 71
40 void FakeIntentHelperInstance::HandleUrlList( 72 void FakeIntentHelperInstance::HandleUrlList(
41 std::vector<mojom::UrlWithMimeTypePtr> urls, 73 std::vector<mojom::UrlWithMimeTypePtr> urls,
42 mojom::ActivityNamePtr activity, 74 mojom::ActivityNamePtr activity,
43 mojom::ActionType action) {} 75 mojom::ActionType action) {}
44 76
45 void FakeIntentHelperInstance::Init(mojom::IntentHelperHostPtr host_ptr) {} 77 void FakeIntentHelperInstance::Init(mojom::IntentHelperHostPtr host_ptr) {}
46 78
47 void FakeIntentHelperInstance::OpenFileToReadDeprecated( 79 void FakeIntentHelperInstance::OpenFileToReadDeprecated(
48 const std::string& url, 80 const std::string& url,
49 const OpenFileToReadDeprecatedCallback& callback) {} 81 const OpenFileToReadDeprecatedCallback& callback) {}
50 82
51 void FakeIntentHelperInstance::RequestActivityIcons( 83 void FakeIntentHelperInstance::RequestActivityIcons(
52 std::vector<mojom::ActivityNamePtr> activities, 84 std::vector<mojom::ActivityNamePtr> activities,
53 ::arc::mojom::ScaleFactor scale_factor, 85 ::arc::mojom::ScaleFactor scale_factor,
54 const RequestActivityIconsCallback& callback) {} 86 const RequestActivityIconsCallback& callback) {}
55 87
56 void FakeIntentHelperInstance::RequestIntentHandlerList( 88 void FakeIntentHelperInstance::RequestIntentHandlerList(
57 mojom::IntentInfoPtr intent, 89 mojom::IntentInfoPtr intent,
58 const RequestIntentHandlerListCallback& callback) {} 90 const RequestIntentHandlerListCallback& callback) {
91 std::vector<mojom::IntentHandlerInfoPtr> handlers;
92 auto it = intent_handlers_.find(intent->action);
93 if (it != intent_handlers_.end()) {
94 handlers = std::move(it->second);
95 intent_handlers_.erase(it);
96 }
97 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
98 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.
99 }
59 100
60 void FakeIntentHelperInstance::RequestUrlHandlerList( 101 void FakeIntentHelperInstance::RequestUrlHandlerList(
61 const std::string& url, 102 const std::string& url,
62 const RequestUrlHandlerListCallback& callback) {} 103 const RequestUrlHandlerListCallback& callback) {}
63 104
64 void FakeIntentHelperInstance::RequestUrlListHandlerList( 105 void FakeIntentHelperInstance::RequestUrlListHandlerList(
65 std::vector<mojom::UrlWithMimeTypePtr> urls, 106 std::vector<mojom::UrlWithMimeTypePtr> urls,
66 const RequestUrlListHandlerListCallback& callback) {} 107 const RequestUrlListHandlerListCallback& callback) {}
67 108
68 void FakeIntentHelperInstance::SendBroadcast(const std::string& action, 109 void FakeIntentHelperInstance::SendBroadcast(const std::string& action,
69 const std::string& package_name, 110 const std::string& package_name,
70 const std::string& cls, 111 const std::string& cls,
71 const std::string& extras) { 112 const std::string& extras) {
72 broadcasts_.emplace_back(action, package_name, cls, extras); 113 broadcasts_.emplace_back(action, package_name, cls, extras);
73 } 114 }
74 115
75 } // namespace arc 116 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698