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