| 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> |
| 11 #include <utility> | |
| 12 #include <vector> | 11 #include <vector> |
| 13 | 12 |
| 14 #include "base/macros.h" | 13 #include "base/macros.h" |
| 15 #include "base/memory/scoped_vector.h" | |
| 16 #include "components/arc/common/app.mojom.h" | 14 #include "components/arc/common/app.mojom.h" |
| 17 #include "mojo/public/cpp/bindings/binding.h" | 15 #include "mojo/public/cpp/bindings/binding.h" |
| 18 | 16 |
| 19 namespace arc { | 17 namespace arc { |
| 20 | 18 |
| 21 class FakeAppInstance : public mojom::AppInstance { | 19 class FakeAppInstance : public mojom::AppInstance { |
| 22 public: | 20 public: |
| 23 class Request { | 21 class Request { |
| 24 public: | 22 public: |
| 25 Request(const std::string& package_name, const std::string& activity) | 23 Request(const std::string& package_name, const std::string& activity) |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 void SetTaskInfo(int32_t task_id, | 128 void SetTaskInfo(int32_t task_id, |
| 131 const std::string& package_name, | 129 const std::string& package_name, |
| 132 const std::string& activity); | 130 const std::string& activity); |
| 133 void SendRefreshPackageList( | 131 void SendRefreshPackageList( |
| 134 const std::vector<mojom::ArcPackageInfo>& packages); | 132 const std::vector<mojom::ArcPackageInfo>& packages); |
| 135 void SendPackageAdded(const mojom::ArcPackageInfo& package); | 133 void SendPackageAdded(const mojom::ArcPackageInfo& package); |
| 136 void SendPackageUninstalled(const mojo::String& pacakge_name); | 134 void SendPackageUninstalled(const mojo::String& pacakge_name); |
| 137 | 135 |
| 138 int refresh_app_list_count() const { return refresh_app_list_count_; } | 136 int refresh_app_list_count() const { return refresh_app_list_count_; } |
| 139 | 137 |
| 140 const ScopedVector<Request>& launch_requests() const { | 138 const std::vector<std::unique_ptr<Request>>& launch_requests() const { |
| 141 return launch_requests_; | 139 return launch_requests_; |
| 142 } | 140 } |
| 143 | 141 |
| 144 const ScopedVector<mojo::String>& launch_intents() const { | 142 const std::vector<std::unique_ptr<mojo::String>>& launch_intents() const { |
| 145 return launch_intents_; | 143 return launch_intents_; |
| 146 } | 144 } |
| 147 | 145 |
| 148 const ScopedVector<IconRequest>& icon_requests() const { | 146 const std::vector<std::unique_ptr<IconRequest>>& icon_requests() const { |
| 149 return icon_requests_; | 147 return icon_requests_; |
| 150 } | 148 } |
| 151 | 149 |
| 152 const ScopedVector<ShortcutIconRequest>& shortcut_icon_requests() const { | 150 const std::vector<std::unique_ptr<ShortcutIconRequest>>& |
| 151 shortcut_icon_requests() const { |
| 153 return shortcut_icon_requests_; | 152 return shortcut_icon_requests_; |
| 154 } | 153 } |
| 155 | 154 |
| 156 private: | 155 private: |
| 157 using TaskIdToInfo = std::map<int32_t, std::unique_ptr<Request>>; | 156 using TaskIdToInfo = std::map<int32_t, std::unique_ptr<Request>>; |
| 158 // Mojo endpoints. | 157 // Mojo endpoints. |
| 159 mojom::AppHost* app_host_; | 158 mojom::AppHost* app_host_; |
| 160 // Number of RefreshAppList calls. | 159 // Number of RefreshAppList calls. |
| 161 int refresh_app_list_count_ = 0; | 160 int refresh_app_list_count_ = 0; |
| 162 // Keeps information about launch requests. | 161 // Keeps information about launch requests. |
| 163 ScopedVector<Request> launch_requests_; | 162 std::vector<std::unique_ptr<Request>> launch_requests_; |
| 164 // Keeps information about launch intents. | 163 // Keeps information about launch intents. |
| 165 ScopedVector<mojo::String> launch_intents_; | 164 std::vector<std::unique_ptr<mojo::String>> launch_intents_; |
| 166 // Keeps information about icon load requests. | 165 // Keeps information about icon load requests. |
| 167 ScopedVector<IconRequest> icon_requests_; | 166 std::vector<std::unique_ptr<IconRequest>> icon_requests_; |
| 168 // Keeps information about shortcut icon load requests. | 167 // Keeps information about shortcut icon load requests. |
| 169 ScopedVector<ShortcutIconRequest> shortcut_icon_requests_; | 168 std::vector<std::unique_ptr<ShortcutIconRequest>> shortcut_icon_requests_; |
| 170 // Keeps information for running tasks. | 169 // Keeps information for running tasks. |
| 171 TaskIdToInfo task_id_to_info_; | 170 TaskIdToInfo task_id_to_info_; |
| 172 | 171 |
| 173 bool GetFakeIcon(mojom::ScaleFactor scale_factor, | 172 bool GetFakeIcon(mojom::ScaleFactor scale_factor, |
| 174 std::string* png_data_as_string); | 173 std::string* png_data_as_string); |
| 175 | 174 |
| 176 DISALLOW_COPY_AND_ASSIGN(FakeAppInstance); | 175 DISALLOW_COPY_AND_ASSIGN(FakeAppInstance); |
| 177 }; | 176 }; |
| 178 | 177 |
| 179 } // namespace arc | 178 } // namespace arc |
| 180 | 179 |
| 181 #endif // COMPONENTS_ARC_TEST_FAKE_APP_INSTANCE_H_ | 180 #endif // COMPONENTS_ARC_TEST_FAKE_APP_INSTANCE_H_ |
| OLD | NEW |