OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_APP_INSTANCE_H_ | 5 #ifndef COMPONENTS_ARC_TEST_FAKE_APP_INSTANCE_H_ |
6 #define COMPONENTS_ARC_TEST_FAKE_APP_INSTANCE_H_ | 6 #define COMPONENTS_ARC_TEST_FAKE_APP_INSTANCE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 private: | 72 private: |
73 std::string icon_resource_id_; | 73 std::string icon_resource_id_; |
74 int scale_factor_; | 74 int scale_factor_; |
75 | 75 |
76 DISALLOW_COPY_AND_ASSIGN(ShortcutIconRequest); | 76 DISALLOW_COPY_AND_ASSIGN(ShortcutIconRequest); |
77 }; | 77 }; |
78 | 78 |
79 explicit FakeAppInstance(mojom::AppHost* app_host); | 79 explicit FakeAppInstance(mojom::AppHost* app_host); |
80 ~FakeAppInstance() override; | 80 ~FakeAppInstance() override; |
81 | 81 |
| 82 void Bind(mojo::InterfaceRequest<mojom::AppInstance> interface_request) { |
| 83 binding_.Bind(std::move(interface_request)); |
| 84 } |
| 85 |
82 // mojom::AppInstance overrides: | 86 // mojom::AppInstance overrides: |
83 void Init(mojom::AppHostPtr host_ptr) override {} | 87 void Init(mojom::AppHostPtr host_ptr) override {} |
84 void RefreshAppList() override; | 88 void RefreshAppList() override; |
85 void LaunchApp(const mojo::String& package_name, | 89 void LaunchApp(const mojo::String& package_name, |
86 const mojo::String& activity, | 90 const mojo::String& activity, |
87 const gfx::Rect& dimension) override; | 91 const gfx::Rect& dimension) override; |
88 void RequestAppIcon(const mojo::String& package_name, | 92 void RequestAppIcon(const mojo::String& package_name, |
89 const mojo::String& activity, | 93 const mojo::String& activity, |
90 mojom::ScaleFactor scale_factor) override; | 94 mojom::ScaleFactor scale_factor) override; |
91 void LaunchIntent(const mojo::String& intent_uri, | 95 void LaunchIntent(const mojo::String& intent_uri, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 } | 145 } |
142 | 146 |
143 const ScopedVector<IconRequest>& icon_requests() const { | 147 const ScopedVector<IconRequest>& icon_requests() const { |
144 return icon_requests_; | 148 return icon_requests_; |
145 } | 149 } |
146 | 150 |
147 const ScopedVector<ShortcutIconRequest>& shortcut_icon_requests() const { | 151 const ScopedVector<ShortcutIconRequest>& shortcut_icon_requests() const { |
148 return shortcut_icon_requests_; | 152 return shortcut_icon_requests_; |
149 } | 153 } |
150 | 154 |
| 155 // This method can be called on tests when a method is intended to |
| 156 // be called across a Mojo proxy. |
| 157 void WaitForIncomingMethodCall(); |
| 158 |
| 159 // As part of the initialization process, the instance side calls |
| 160 // mojom::AppHost::OnAppInstanceReady(), which in turn calls |
| 161 // mojom::AppInstance::Init() and |
| 162 // mojom::AppInstance::RefreshAppList(). This method should be called after a |
| 163 // call |
| 164 // to mojom::ArcBridgeHost::OnAppInstanceReady() to make sure all method calls |
| 165 // have |
| 166 // been dispatched. |
| 167 void WaitForOnAppInstanceReady(); |
| 168 |
151 private: | 169 private: |
152 using TaskIdToInfo = std::map<int32_t, std::unique_ptr<Request>>; | 170 using TaskIdToInfo = std::map<int32_t, std::unique_ptr<Request>>; |
153 // Mojo endpoints. | 171 // Mojo endpoints. |
| 172 mojo::Binding<mojom::AppInstance> binding_; |
154 mojom::AppHost* app_host_; | 173 mojom::AppHost* app_host_; |
155 // Number of RefreshAppList calls. | 174 // Number of RefreshAppList calls. |
156 int refresh_app_list_count_ = 0; | 175 int refresh_app_list_count_ = 0; |
157 // Keeps information about launch requests. | 176 // Keeps information about launch requests. |
158 ScopedVector<Request> launch_requests_; | 177 ScopedVector<Request> launch_requests_; |
159 // Keeps information about launch intents. | 178 // Keeps information about launch intents. |
160 ScopedVector<mojo::String> launch_intents_; | 179 ScopedVector<mojo::String> launch_intents_; |
161 // Keeps information about icon load requests. | 180 // Keeps information about icon load requests. |
162 ScopedVector<IconRequest> icon_requests_; | 181 ScopedVector<IconRequest> icon_requests_; |
163 // Keeps information about shortcut icon load requests. | 182 // Keeps information about shortcut icon load requests. |
164 ScopedVector<ShortcutIconRequest> shortcut_icon_requests_; | 183 ScopedVector<ShortcutIconRequest> shortcut_icon_requests_; |
165 // Keeps information for running tasks. | 184 // Keeps information for running tasks. |
166 TaskIdToInfo task_id_to_info_; | 185 TaskIdToInfo task_id_to_info_; |
167 | 186 |
168 bool GetFakeIcon(mojom::ScaleFactor scale_factor, | 187 bool GetFakeIcon(mojom::ScaleFactor scale_factor, |
169 std::string* png_data_as_string); | 188 std::string* png_data_as_string); |
170 | 189 |
171 DISALLOW_COPY_AND_ASSIGN(FakeAppInstance); | 190 DISALLOW_COPY_AND_ASSIGN(FakeAppInstance); |
172 }; | 191 }; |
173 | 192 |
174 } // namespace arc | 193 } // namespace arc |
175 | 194 |
176 #endif // COMPONENTS_ARC_TEST_FAKE_APP_INSTANCE_H_ | 195 #endif // COMPONENTS_ARC_TEST_FAKE_APP_INSTANCE_H_ |
OLD | NEW |