Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Side by Side Diff: components/arc/test/fake_app_instance.h

Issue 2138513002: arc: Use the new InstanceHolder for unittests (Closed) Base URL: https://chromium.googlesource.com/a/chromium/src.git@bridge_refactor_first
Patch Set: Rebase Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/arc/arc_bridge_service_impl.cc ('k') | components/arc/test/fake_app_instance.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
86 // mojom::AppInstance overrides: 82 // mojom::AppInstance overrides:
87 void Init(mojom::AppHostPtr host_ptr) override {} 83 void Init(mojom::AppHostPtr host_ptr) override {}
88 void RefreshAppList() override; 84 void RefreshAppList() override;
89 void LaunchApp(const mojo::String& package_name, 85 void LaunchApp(const mojo::String& package_name,
90 const mojo::String& activity, 86 const mojo::String& activity,
91 const gfx::Rect& dimension) override; 87 const gfx::Rect& dimension) override;
92 void RequestAppIcon(const mojo::String& package_name, 88 void RequestAppIcon(const mojo::String& package_name,
93 const mojo::String& activity, 89 const mojo::String& activity,
94 mojom::ScaleFactor scale_factor) override; 90 mojom::ScaleFactor scale_factor) override;
95 void LaunchIntent(const mojo::String& intent_uri, 91 void LaunchIntent(const mojo::String& intent_uri,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 } 141 }
146 142
147 const ScopedVector<IconRequest>& icon_requests() const { 143 const ScopedVector<IconRequest>& icon_requests() const {
148 return icon_requests_; 144 return icon_requests_;
149 } 145 }
150 146
151 const ScopedVector<ShortcutIconRequest>& shortcut_icon_requests() const { 147 const ScopedVector<ShortcutIconRequest>& shortcut_icon_requests() const {
152 return shortcut_icon_requests_; 148 return shortcut_icon_requests_;
153 } 149 }
154 150
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
169 private: 151 private:
170 using TaskIdToInfo = std::map<int32_t, std::unique_ptr<Request>>; 152 using TaskIdToInfo = std::map<int32_t, std::unique_ptr<Request>>;
171 // Mojo endpoints. 153 // Mojo endpoints.
172 mojo::Binding<mojom::AppInstance> binding_;
173 mojom::AppHost* app_host_; 154 mojom::AppHost* app_host_;
174 // Number of RefreshAppList calls. 155 // Number of RefreshAppList calls.
175 int refresh_app_list_count_ = 0; 156 int refresh_app_list_count_ = 0;
176 // Keeps information about launch requests. 157 // Keeps information about launch requests.
177 ScopedVector<Request> launch_requests_; 158 ScopedVector<Request> launch_requests_;
178 // Keeps information about launch intents. 159 // Keeps information about launch intents.
179 ScopedVector<mojo::String> launch_intents_; 160 ScopedVector<mojo::String> launch_intents_;
180 // Keeps information about icon load requests. 161 // Keeps information about icon load requests.
181 ScopedVector<IconRequest> icon_requests_; 162 ScopedVector<IconRequest> icon_requests_;
182 // Keeps information about shortcut icon load requests. 163 // Keeps information about shortcut icon load requests.
183 ScopedVector<ShortcutIconRequest> shortcut_icon_requests_; 164 ScopedVector<ShortcutIconRequest> shortcut_icon_requests_;
184 // Keeps information for running tasks. 165 // Keeps information for running tasks.
185 TaskIdToInfo task_id_to_info_; 166 TaskIdToInfo task_id_to_info_;
186 167
187 bool GetFakeIcon(mojom::ScaleFactor scale_factor, 168 bool GetFakeIcon(mojom::ScaleFactor scale_factor,
188 std::string* png_data_as_string); 169 std::string* png_data_as_string);
189 170
190 DISALLOW_COPY_AND_ASSIGN(FakeAppInstance); 171 DISALLOW_COPY_AND_ASSIGN(FakeAppInstance);
191 }; 172 };
192 173
193 } // namespace arc 174 } // namespace arc
194 175
195 #endif // COMPONENTS_ARC_TEST_FAKE_APP_INSTANCE_H_ 176 #endif // COMPONENTS_ARC_TEST_FAKE_APP_INSTANCE_H_
OLDNEW
« no previous file with comments | « components/arc/arc_bridge_service_impl.cc ('k') | components/arc/test/fake_app_instance.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698