| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 74 |
| 75 DISALLOW_COPY_AND_ASSIGN(ShortcutIconRequest); | 75 DISALLOW_COPY_AND_ASSIGN(ShortcutIconRequest); |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 explicit FakeAppInstance(mojom::AppHost* app_host); | 78 explicit FakeAppInstance(mojom::AppHost* app_host); |
| 79 ~FakeAppInstance() override; | 79 ~FakeAppInstance() override; |
| 80 | 80 |
| 81 // mojom::AppInstance overrides: | 81 // mojom::AppInstance overrides: |
| 82 void Init(mojom::AppHostPtr host_ptr) override {} | 82 void Init(mojom::AppHostPtr host_ptr) override {} |
| 83 void RefreshAppList() override; | 83 void RefreshAppList() override; |
| 84 void LaunchApp(const mojo::String& package_name, | 84 void LaunchApp(const std::string& package_name, |
| 85 const mojo::String& activity, | 85 const std::string& activity, |
| 86 const base::Optional<gfx::Rect>& dimension) override; | 86 const base::Optional<gfx::Rect>& dimension) override; |
| 87 void RequestAppIcon(const mojo::String& package_name, | 87 void RequestAppIcon(const std::string& package_name, |
| 88 const mojo::String& activity, | 88 const std::string& activity, |
| 89 mojom::ScaleFactor scale_factor) override; | 89 mojom::ScaleFactor scale_factor) override; |
| 90 void LaunchIntent( | 90 void LaunchIntent( |
| 91 const mojo::String& intent_uri, | 91 const std::string& intent_uri, |
| 92 const base::Optional<gfx::Rect>& dimension_on_screen) override; | 92 const base::Optional<gfx::Rect>& dimension_on_screen) override; |
| 93 void RequestIcon(const mojo::String& icon_resource_id, | 93 void RequestIcon(const std::string& icon_resource_id, |
| 94 mojom::ScaleFactor scale_factor, | 94 mojom::ScaleFactor scale_factor, |
| 95 const RequestIconCallback& callback) override; | 95 const RequestIconCallback& callback) override; |
| 96 void RemoveCachedIcon(const mojo::String& icon_resource_id) override; | 96 void RemoveCachedIcon(const std::string& icon_resource_id) override; |
| 97 void CanHandleResolution( | 97 void CanHandleResolution( |
| 98 const mojo::String& package_name, | 98 const std::string& package_name, |
| 99 const mojo::String& activity, | 99 const std::string& activity, |
| 100 const gfx::Rect& dimension, | 100 const gfx::Rect& dimension, |
| 101 const CanHandleResolutionCallback& callback) override; | 101 const CanHandleResolutionCallback& callback) override; |
| 102 void UninstallPackage(const mojo::String& package_name) override; | 102 void UninstallPackage(const std::string& package_name) override; |
| 103 void GetTaskInfo(int32_t task_id, | 103 void GetTaskInfo(int32_t task_id, |
| 104 const GetTaskInfoCallback& callback) override; | 104 const GetTaskInfoCallback& callback) override; |
| 105 void SetTaskActive(int32_t task_id) override; | 105 void SetTaskActive(int32_t task_id) override; |
| 106 void CloseTask(int32_t task_id) override; | 106 void CloseTask(int32_t task_id) override; |
| 107 void ShowPackageInfoDeprecated(const mojo::String& package_name, | 107 void ShowPackageInfoDeprecated(const std::string& package_name, |
| 108 const gfx::Rect& dimension_on_screen) override; | 108 const gfx::Rect& dimension_on_screen) override; |
| 109 void ShowPackageInfoOnPage(const mojo::String& package_name, | 109 void ShowPackageInfoOnPage(const std::string& package_name, |
| 110 mojom::ShowPackageInfoPage page, | 110 mojom::ShowPackageInfoPage page, |
| 111 const gfx::Rect& dimension_on_screen) override; | 111 const gfx::Rect& dimension_on_screen) override; |
| 112 void SetNotificationsEnabled(const mojo::String& package_name, | 112 void SetNotificationsEnabled(const std::string& package_name, |
| 113 bool enabled) override; | 113 bool enabled) override; |
| 114 void InstallPackage(mojom::ArcPackageInfoPtr arcPackageInfo) override; | 114 void InstallPackage(mojom::ArcPackageInfoPtr arcPackageInfo) override; |
| 115 | 115 |
| 116 // Methods to reply messages. | 116 // Methods to reply messages. |
| 117 void SendRefreshAppList(const std::vector<mojom::AppInfo>& apps); | 117 void SendRefreshAppList(const std::vector<mojom::AppInfo>& apps); |
| 118 void SendAppAdded(const mojom::AppInfo& app); | 118 void SendAppAdded(const mojom::AppInfo& app); |
| 119 void SendPackageAppListRefreshed(const mojo::String& package_name, | 119 void SendPackageAppListRefreshed(const std::string& package_name, |
| 120 const std::vector<mojom::AppInfo>& apps); | 120 const std::vector<mojom::AppInfo>& apps); |
| 121 void SendTaskCreated(int32_t taskId, const mojom::AppInfo& app); | 121 void SendTaskCreated(int32_t taskId, const mojom::AppInfo& app); |
| 122 void SendTaskDestroyed(int32_t taskId); | 122 void SendTaskDestroyed(int32_t taskId); |
| 123 bool GenerateAndSendIcon(const mojom::AppInfo& app, | 123 bool GenerateAndSendIcon(const mojom::AppInfo& app, |
| 124 mojom::ScaleFactor scale_factor, | 124 mojom::ScaleFactor scale_factor, |
| 125 std::string* png_data_as_string); | 125 std::string* png_data_as_string); |
| 126 void SendInstallShortcut(const mojom::ShortcutInfo& shortcuts); | 126 void SendInstallShortcut(const mojom::ShortcutInfo& shortcuts); |
| 127 void SendInstallShortcuts(const std::vector<mojom::ShortcutInfo>& shortcuts); | 127 void SendInstallShortcuts(const std::vector<mojom::ShortcutInfo>& shortcuts); |
| 128 void SetTaskInfo(int32_t task_id, | 128 void SetTaskInfo(int32_t task_id, |
| 129 const std::string& package_name, | 129 const std::string& package_name, |
| 130 const std::string& activity); | 130 const std::string& activity); |
| 131 void SendRefreshPackageList( | 131 void SendRefreshPackageList( |
| 132 const std::vector<mojom::ArcPackageInfo>& packages); | 132 const std::vector<mojom::ArcPackageInfo>& packages); |
| 133 void SendPackageAdded(const mojom::ArcPackageInfo& package); | 133 void SendPackageAdded(const mojom::ArcPackageInfo& package); |
| 134 void SendPackageUninstalled(const mojo::String& pacakge_name); | 134 void SendPackageUninstalled(const std::string& pacakge_name); |
| 135 | 135 |
| 136 int refresh_app_list_count() const { return refresh_app_list_count_; } | 136 int refresh_app_list_count() const { return refresh_app_list_count_; } |
| 137 | 137 |
| 138 const std::vector<std::unique_ptr<Request>>& launch_requests() const { | 138 const std::vector<std::unique_ptr<Request>>& launch_requests() const { |
| 139 return launch_requests_; | 139 return launch_requests_; |
| 140 } | 140 } |
| 141 | 141 |
| 142 const std::vector<std::unique_ptr<mojo::String>>& launch_intents() const { | 142 const std::vector<std::string>& launch_intents() const { |
| 143 return launch_intents_; | 143 return launch_intents_; |
| 144 } | 144 } |
| 145 | 145 |
| 146 const std::vector<std::unique_ptr<IconRequest>>& icon_requests() const { | 146 const std::vector<std::unique_ptr<IconRequest>>& icon_requests() const { |
| 147 return icon_requests_; | 147 return icon_requests_; |
| 148 } | 148 } |
| 149 | 149 |
| 150 const std::vector<std::unique_ptr<ShortcutIconRequest>>& | 150 const std::vector<std::unique_ptr<ShortcutIconRequest>>& |
| 151 shortcut_icon_requests() const { | 151 shortcut_icon_requests() const { |
| 152 return shortcut_icon_requests_; | 152 return shortcut_icon_requests_; |
| 153 } | 153 } |
| 154 | 154 |
| 155 private: | 155 private: |
| 156 using TaskIdToInfo = std::map<int32_t, std::unique_ptr<Request>>; | 156 using TaskIdToInfo = std::map<int32_t, std::unique_ptr<Request>>; |
| 157 // Mojo endpoints. | 157 // Mojo endpoints. |
| 158 mojom::AppHost* app_host_; | 158 mojom::AppHost* app_host_; |
| 159 // Number of RefreshAppList calls. | 159 // Number of RefreshAppList calls. |
| 160 int refresh_app_list_count_ = 0; | 160 int refresh_app_list_count_ = 0; |
| 161 // Keeps information about launch requests. | 161 // Keeps information about launch requests. |
| 162 std::vector<std::unique_ptr<Request>> launch_requests_; | 162 std::vector<std::unique_ptr<Request>> launch_requests_; |
| 163 // Keeps information about launch intents. | 163 // Keeps information about launch intents. |
| 164 std::vector<std::unique_ptr<mojo::String>> launch_intents_; | 164 std::vector<std::string> launch_intents_; |
| 165 // Keeps information about icon load requests. | 165 // Keeps information about icon load requests. |
| 166 std::vector<std::unique_ptr<IconRequest>> icon_requests_; | 166 std::vector<std::unique_ptr<IconRequest>> icon_requests_; |
| 167 // Keeps information about shortcut icon load requests. | 167 // Keeps information about shortcut icon load requests. |
| 168 std::vector<std::unique_ptr<ShortcutIconRequest>> shortcut_icon_requests_; | 168 std::vector<std::unique_ptr<ShortcutIconRequest>> shortcut_icon_requests_; |
| 169 // Keeps information for running tasks. | 169 // Keeps information for running tasks. |
| 170 TaskIdToInfo task_id_to_info_; | 170 TaskIdToInfo task_id_to_info_; |
| 171 | 171 |
| 172 bool GetFakeIcon(mojom::ScaleFactor scale_factor, | 172 bool GetFakeIcon(mojom::ScaleFactor scale_factor, |
| 173 std::string* png_data_as_string); | 173 std::string* png_data_as_string); |
| 174 | 174 |
| 175 DISALLOW_COPY_AND_ASSIGN(FakeAppInstance); | 175 DISALLOW_COPY_AND_ASSIGN(FakeAppInstance); |
| 176 }; | 176 }; |
| 177 | 177 |
| 178 } // namespace arc | 178 } // namespace arc |
| 179 | 179 |
| 180 #endif // COMPONENTS_ARC_TEST_FAKE_APP_INSTANCE_H_ | 180 #endif // COMPONENTS_ARC_TEST_FAKE_APP_INSTANCE_H_ |
| OLD | NEW |