Chromium Code Reviews| 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 <string> | 9 #include <string> |
| 9 #include <vector> | 10 #include <vector> |
| 10 | 11 |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
| 13 #include "components/arc/common/app.mojom.h" | 14 #include "components/arc/common/app.mojom.h" |
| 14 #include "mojo/public/cpp/bindings/binding.h" | 15 #include "mojo/public/cpp/bindings/binding.h" |
| 15 | 16 |
| 16 namespace arc { | 17 namespace arc { |
| 17 | 18 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 const mojo::String& activity, | 71 const mojo::String& activity, |
| 71 ScreenRectPtr dimension) override; | 72 ScreenRectPtr dimension) override; |
| 72 void RequestAppIcon(const mojo::String& package_name, | 73 void RequestAppIcon(const mojo::String& package_name, |
| 73 const mojo::String& activity, | 74 const mojo::String& activity, |
| 74 ScaleFactor scale_factor) override; | 75 ScaleFactor scale_factor) override; |
| 75 void CanHandleResolution(const mojo::String& package_name, | 76 void CanHandleResolution(const mojo::String& package_name, |
| 76 const mojo::String& activity, | 77 const mojo::String& activity, |
| 77 ScreenRectPtr dimension, | 78 ScreenRectPtr dimension, |
| 78 const CanHandleResolutionCallback& callback) override; | 79 const CanHandleResolutionCallback& callback) override; |
| 79 void UninstallPackage(const mojo::String& package_name) override; | 80 void UninstallPackage(const mojo::String& package_name) override; |
| 81 void GetTaskInfo(int32_t task_id, | |
| 82 const GetTaskInfoCallback& callback) override; | |
| 80 | 83 |
| 81 // Methods to reply messages. | 84 // Methods to reply messages. |
| 82 void SendRefreshAppList(const std::vector<AppInfo>& apps); | 85 void SendRefreshAppList(const std::vector<AppInfo>& apps); |
| 83 bool GenerateAndSendIcon(const AppInfo& app, | 86 bool GenerateAndSendIcon(const AppInfo& app, |
| 84 ScaleFactor scale_factor, | 87 ScaleFactor scale_factor, |
| 85 std::string* png_data_as_string); | 88 std::string* png_data_as_string); |
| 89 void SetTaskInfo(int task_id, | |
|
Luis Héctor Chávez
2016/03/25 16:12:25
nit: int32_t for consistency.
khmel
2016/03/28 17:17:31
Done.
| |
| 90 const std::string& package_name, | |
| 91 const std::string& activity); | |
| 86 | 92 |
| 87 int refresh_app_list_count() const { return refresh_app_list_count_; } | 93 int refresh_app_list_count() const { return refresh_app_list_count_; } |
| 88 | 94 |
| 89 const ScopedVector<Request>& launch_requests() const { | 95 const ScopedVector<Request>& launch_requests() const { |
| 90 return launch_requests_; | 96 return launch_requests_; |
| 91 } | 97 } |
| 92 | 98 |
| 93 const ScopedVector<IconRequest>& icon_requests() const { | 99 const ScopedVector<IconRequest>& icon_requests() const { |
| 94 return icon_requests_; | 100 return icon_requests_; |
| 95 } | 101 } |
| 96 | 102 |
| 97 // This method can be called on tests when a method is intended to | 103 // This method can be called on tests when a method is intended to |
| 98 // be called across a Mojo proxy. | 104 // be called across a Mojo proxy. |
| 99 void WaitForIncomingMethodCall(); | 105 void WaitForIncomingMethodCall(); |
| 100 | 106 |
| 101 // As part of the initialization process, the instance side calls | 107 // As part of the initialization process, the instance side calls |
| 102 // AppHost::OnAppInstanceReady(), which in turn calls AppInstance::Init() and | 108 // AppHost::OnAppInstanceReady(), which in turn calls AppInstance::Init() and |
| 103 // AppInstance::RefreshAppList(). This method should be called after a call | 109 // AppInstance::RefreshAppList(). This method should be called after a call |
| 104 // to ArcBridgeHost::OnAppInstanceReady() to make sure all method calls have | 110 // to ArcBridgeHost::OnAppInstanceReady() to make sure all method calls have |
| 105 // been dispatched. | 111 // been dispatched. |
| 106 void WaitForOnAppInstanceReady(); | 112 void WaitForOnAppInstanceReady(); |
| 107 | 113 |
| 108 private: | 114 private: |
| 115 using TaskIdToInfo = std::map<int32_t, scoped_ptr<Request>>; | |
| 109 // Mojo endpoints. | 116 // Mojo endpoints. |
| 110 mojo::Binding<AppInstance> binding_; | 117 mojo::Binding<AppInstance> binding_; |
| 111 AppHost* app_host_; | 118 AppHost* app_host_; |
| 112 // Number of RefreshAppList calls. | 119 // Number of RefreshAppList calls. |
| 113 int refresh_app_list_count_ = 0; | 120 int refresh_app_list_count_ = 0; |
| 114 // Keeps information about launch requests. | 121 // Keeps information about launch requests. |
| 115 ScopedVector<Request> launch_requests_; | 122 ScopedVector<Request> launch_requests_; |
| 116 // Keeps information about icon load requests. | 123 // Keeps information about icon load requests. |
| 117 ScopedVector<IconRequest> icon_requests_; | 124 ScopedVector<IconRequest> icon_requests_; |
| 125 // Keeps information for running tasks. | |
| 126 TaskIdToInfo task_id_to_info_; | |
| 127 | |
| 128 DISALLOW_COPY_AND_ASSIGN(FakeAppInstance); | |
| 118 }; | 129 }; |
| 119 | 130 |
| 120 } // namespace arc | 131 } // namespace arc |
| 121 | 132 |
| 122 #endif // COMPONENTS_ARC_TEST_FAKE_APP_INSTANCE_H_ | 133 #endif // COMPONENTS_ARC_TEST_FAKE_APP_INSTANCE_H_ |
| OLD | NEW |