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

Side by Side Diff: chrome/browser/ui/app_list/arc/arc_app_unittest.cc

Issue 1541653002: Reland "arc-bridge: Move most methods to Mojo interfaces" (Closed) Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: Fixed version Created 5 years 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 | « chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc ('k') | components/arc.gypi » ('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 #include <algorithm> 5 #include <algorithm>
6 #include <map> 6 #include <map>
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
12 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
15 #include "base/task_runner_util.h" 15 #include "base/task_runner_util.h"
16 #include "chrome/browser/ui/app_list/app_list_test_util.h" 16 #include "chrome/browser/ui/app_list/app_list_test_util.h"
17 #include "chrome/browser/ui/app_list/arc/arc_app_icon.h" 17 #include "chrome/browser/ui/app_list/arc/arc_app_icon.h"
18 #include "chrome/browser/ui/app_list/arc/arc_app_item.h" 18 #include "chrome/browser/ui/app_list/arc/arc_app_item.h"
19 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" 19 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
20 #include "chrome/browser/ui/app_list/arc/arc_app_model_builder.h" 20 #include "chrome/browser/ui/app_list/arc/arc_app_model_builder.h"
21 #include "chrome/browser/ui/app_list/test/test_app_list_controller_delegate.h" 21 #include "chrome/browser/ui/app_list/test/test_app_list_controller_delegate.h"
22 #include "chrome/test/base/testing_profile.h" 22 #include "chrome/test/base/testing_profile.h"
23 #include "components/arc/arc_bridge_service.h" 23 #include "components/arc/arc_bridge_service.h"
24 #include "components/arc/test/fake_app_instance.h"
24 #include "components/arc/test/fake_arc_bridge_service.h" 25 #include "components/arc/test/fake_arc_bridge_service.h"
25 #include "content/public/browser/browser_thread.h" 26 #include "content/public/browser/browser_thread.h"
26 #include "testing/gtest/include/gtest/gtest.h" 27 #include "testing/gtest/include/gtest/gtest.h"
27 #include "ui/app_list/app_list_model.h" 28 #include "ui/app_list/app_list_model.h"
28 #include "ui/gfx/image/image_skia.h" 29 #include "ui/gfx/image/image_skia.h"
29 30
30 namespace { 31 namespace {
31 32
32 std::string GetAppId(const arc::AppInfo& app_info) { 33 std::string GetAppId(const arc::AppInfo& app_info) {
33 return ArcAppListPrefs::GetAppId(app_info.package, app_info.activity); 34 return ArcAppListPrefs::GetAppId(app_info.package, app_info.activity);
(...skipping 19 matching lines...) Expand all
53 base::snprintf(buffer, arraysize(buffer), "Fake App %d", i); 54 base::snprintf(buffer, arraysize(buffer), "Fake App %d", i);
54 app.name = buffer; 55 app.name = buffer;
55 base::snprintf(buffer, arraysize(buffer), "fake.app.%d", i); 56 base::snprintf(buffer, arraysize(buffer), "fake.app.%d", i);
56 app.package = buffer; 57 app.package = buffer;
57 base::snprintf(buffer, arraysize(buffer), "fake.app.%d.activity", i); 58 base::snprintf(buffer, arraysize(buffer), "fake.app.%d.activity", i);
58 app.activity = buffer; 59 app.activity = buffer;
59 fake_apps_.push_back(app); 60 fake_apps_.push_back(app);
60 } 61 }
61 62
62 bridge_service_.reset(new arc::FakeArcBridgeService()); 63 bridge_service_.reset(new arc::FakeArcBridgeService());
64 app_instance_.reset(
65 new arc::FakeAppInstance(ArcAppListPrefs::Get(profile_.get())));
66 arc::AppInstancePtr instance;
67 app_instance_->Bind(mojo::GetProxy(&instance));
68 bridge_service_->OnAppInstanceReady(std::move(instance));
69 // Wait for Init() and then RefreshAppList().
70 app_instance_->WaitForIncomingMethodCall();
dcheng 2015/12/20 01:49:45 Too bad there isn't some sort of way to be more ex
xiyuan 2015/12/21 17:05:53 Yeah, this is confusing to read. Can we add someth
Luis Héctor Chávez 2015/12/21 17:24:21 Done.
71 app_instance_->WaitForIncomingMethodCall();
63 72
64 // Check initial conditions. 73 // Check initial conditions.
65 EXPECT_EQ(bridge_service_.get(), arc::ArcBridgeService::Get()); 74 EXPECT_EQ(bridge_service_.get(), arc::ArcBridgeService::Get());
66 EXPECT_EQ(true, !arc::ArcBridgeService::Get()->available()); 75 EXPECT_EQ(true, !arc::ArcBridgeService::Get()->available());
67 EXPECT_EQ(arc::ArcBridgeService::State::STOPPED, 76 EXPECT_EQ(arc::ArcBridgeService::State::STOPPED,
68 arc::ArcBridgeService::Get()->state()); 77 arc::ArcBridgeService::Get()->state());
69 78
70 CreateBuilder(); 79 CreateBuilder();
71 80
72 // At this point we should have ArcAppListPrefs as observer of service. 81 // At this point we should have ArcAppListPrefs as observer of service.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 191
183 // Process the rest of the apps. 192 // Process the rest of the apps.
184 for (auto& id : ids) { 193 for (auto& id : ids) {
185 scoped_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(id); 194 scoped_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(id);
186 ASSERT_NE(nullptr, app_info.get()); 195 ASSERT_NE(nullptr, app_info.get());
187 EXPECT_NE(ready, app_info->ready); 196 EXPECT_NE(ready, app_info->ready);
188 const ArcAppItem* app_item = FindArcItem(id); 197 const ArcAppItem* app_item = FindArcItem(id);
189 ASSERT_NE(nullptr, app_item); 198 ASSERT_NE(nullptr, app_item);
190 EXPECT_NE(ready, app_item->ready()); 199 EXPECT_NE(ready, app_item->ready());
191 } 200 }
192
193 } 201 }
194 202
195 AppListControllerDelegate* controller() { return controller_.get(); } 203 AppListControllerDelegate* controller() { return controller_.get(); }
196 204
197 arc::FakeArcBridgeService* bridge_service() { return bridge_service_.get(); } 205 arc::FakeArcBridgeService* bridge_service() { return bridge_service_.get(); }
198 206
207 arc::FakeAppInstance* app_instance() { return app_instance_.get(); }
208
199 const std::vector<arc::AppInfo>& fake_apps() const { return fake_apps_; } 209 const std::vector<arc::AppInfo>& fake_apps() const { return fake_apps_; }
200 210
201 private: 211 private:
202 scoped_ptr<app_list::AppListModel> model_; 212 scoped_ptr<app_list::AppListModel> model_;
203 scoped_ptr<test::TestAppListControllerDelegate> controller_; 213 scoped_ptr<test::TestAppListControllerDelegate> controller_;
204 scoped_ptr<ArcAppModelBuilder> builder_; 214 scoped_ptr<ArcAppModelBuilder> builder_;
205 scoped_ptr<arc::FakeArcBridgeService> bridge_service_; 215 scoped_ptr<arc::FakeArcBridgeService> bridge_service_;
216 scoped_ptr<arc::FakeAppInstance> app_instance_;
206 std::vector<arc::AppInfo> fake_apps_; 217 std::vector<arc::AppInfo> fake_apps_;
207 218
208 DISALLOW_COPY_AND_ASSIGN(ArcAppModelBuilderTest); 219 DISALLOW_COPY_AND_ASSIGN(ArcAppModelBuilderTest);
209 }; 220 };
210 221
211 TEST_F(ArcAppModelBuilderTest, RefreshAllOnReady) { 222 TEST_F(ArcAppModelBuilderTest, RefreshAllOnReady) {
212 EXPECT_EQ(0, bridge_service()->refresh_app_list_count()); 223 // There should already have been one call, when the interface was
224 // registered.
225 EXPECT_EQ(1, app_instance()->refresh_app_list_count());
213 bridge_service()->SetReady(); 226 bridge_service()->SetReady();
214 EXPECT_EQ(1, bridge_service()->refresh_app_list_count()); 227 app_instance()->RefreshAppList();
228 EXPECT_EQ(2, app_instance()->refresh_app_list_count());
215 } 229 }
216 230
217 TEST_F(ArcAppModelBuilderTest, RefreshAllFillsContent) { 231 TEST_F(ArcAppModelBuilderTest, RefreshAllFillsContent) {
218 ValidateHaveApps(std::vector<arc::AppInfo>()); 232 ValidateHaveApps(std::vector<arc::AppInfo>());
219 bridge_service()->SetReady(); 233 bridge_service()->SetReady();
220 bridge_service()->SendRefreshAppList(fake_apps()); 234 app_instance()->RefreshAppList();
235 app_instance()->SendRefreshAppList(fake_apps());
221 ValidateHaveApps(fake_apps()); 236 ValidateHaveApps(fake_apps());
222 } 237 }
223 238
224 TEST_F(ArcAppModelBuilderTest, MultipleRefreshAll) { 239 TEST_F(ArcAppModelBuilderTest, MultipleRefreshAll) {
225 ValidateHaveApps(std::vector<arc::AppInfo>()); 240 ValidateHaveApps(std::vector<arc::AppInfo>());
226 bridge_service()->SetReady(); 241 bridge_service()->SetReady();
242 app_instance()->RefreshAppList();
227 // Send info about all fake apps except last. 243 // Send info about all fake apps except last.
228 std::vector<arc::AppInfo> apps1(fake_apps().begin(), fake_apps().end() - 1); 244 std::vector<arc::AppInfo> apps1(fake_apps().begin(), fake_apps().end() - 1);
229 bridge_service()->SendRefreshAppList(apps1); 245 app_instance()->SendRefreshAppList(apps1);
230 // At this point all apps (except last) should exist and be ready. 246 // At this point all apps (except last) should exist and be ready.
231 ValidateHaveApps(apps1); 247 ValidateHaveApps(apps1);
232 ValidateAppReadyState(apps1, true); 248 ValidateAppReadyState(apps1, true);
233 249
234 // Send info about all fake apps except first. 250 // Send info about all fake apps except first.
235 std::vector<arc::AppInfo> apps2(fake_apps().begin() + 1, fake_apps().end()); 251 std::vector<arc::AppInfo> apps2(fake_apps().begin() + 1, fake_apps().end());
236 bridge_service()->SendRefreshAppList(apps2); 252 app_instance()->SendRefreshAppList(apps2);
237 // At this point all apps should exist but first one should be non-ready. 253 // At this point all apps should exist but first one should be non-ready.
238 ValidateHaveApps(fake_apps()); 254 ValidateHaveApps(fake_apps());
239 ValidateAppReadyState(apps2, true); 255 ValidateAppReadyState(apps2, true);
240 256
241 // Send info about all fake apps. 257 // Send info about all fake apps.
242 bridge_service()->SendRefreshAppList(fake_apps()); 258 app_instance()->SendRefreshAppList(fake_apps());
243 // At this point all apps should exist and be ready. 259 // At this point all apps should exist and be ready.
244 ValidateHaveApps(fake_apps()); 260 ValidateHaveApps(fake_apps());
245 ValidateAppReadyState(fake_apps(), true); 261 ValidateAppReadyState(fake_apps(), true);
246 262
247 // Send info no app available. 263 // Send info no app available.
248 bridge_service()->SendRefreshAppList(std::vector<arc::AppInfo>()); 264 app_instance()->SendRefreshAppList(std::vector<arc::AppInfo>());
249 // At this point all apps should exist and be non-ready. 265 // At this point all apps should exist and be non-ready.
250 ValidateHaveApps(fake_apps()); 266 ValidateHaveApps(fake_apps());
251 ValidateAppReadyState(fake_apps(), false); 267 ValidateAppReadyState(fake_apps(), false);
252 } 268 }
253 269
254 TEST_F(ArcAppModelBuilderTest, StopServiceDisablesApps) { 270 TEST_F(ArcAppModelBuilderTest, StopServiceDisablesApps) {
255 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); 271 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get());
256 ASSERT_NE(nullptr, prefs); 272 ASSERT_NE(nullptr, prefs);
257 273
258 bridge_service()->SetReady(); 274 bridge_service()->SetReady();
275 app_instance()->RefreshAppList();
259 EXPECT_EQ(static_cast<size_t>(0), GetArcItemCount()); 276 EXPECT_EQ(static_cast<size_t>(0), GetArcItemCount());
260 EXPECT_EQ(static_cast<size_t>(0), prefs->GetAppIds().size()); 277 EXPECT_EQ(static_cast<size_t>(0), prefs->GetAppIds().size());
261 278
262 bridge_service()->SendRefreshAppList(fake_apps()); 279 app_instance()->SendRefreshAppList(fake_apps());
263 std::vector<std::string> ids = prefs->GetAppIds(); 280 std::vector<std::string> ids = prefs->GetAppIds();
264 EXPECT_EQ(fake_apps().size(), ids.size()); 281 EXPECT_EQ(fake_apps().size(), ids.size());
265 ValidateAppReadyState(fake_apps(), true); 282 ValidateAppReadyState(fake_apps(), true);
266 283
267 // Stopping service does not delete items. It makes them non-ready. 284 // Stopping service does not delete items. It makes them non-ready.
268 bridge_service()->SetStopped(); 285 bridge_service()->SetStopped();
269 // Ids should be the same. 286 // Ids should be the same.
270 EXPECT_EQ(ids, prefs->GetAppIds()); 287 EXPECT_EQ(ids, prefs->GetAppIds());
271 ValidateAppReadyState(fake_apps(), false); 288 ValidateAppReadyState(fake_apps(), false);
272 } 289 }
273 290
274 TEST_F(ArcAppModelBuilderTest, LaunchApps) { 291 TEST_F(ArcAppModelBuilderTest, LaunchApps) {
275 // Disable attempts to dismiss app launcher view. 292 // Disable attempts to dismiss app launcher view.
276 ChromeAppListItem::OverrideAppListControllerDelegateForTesting(controller()); 293 ChromeAppListItem::OverrideAppListControllerDelegateForTesting(controller());
277 294
278 bridge_service()->SetReady(); 295 bridge_service()->SetReady();
279 bridge_service()->SendRefreshAppList(fake_apps()); 296 app_instance()->RefreshAppList();
297 app_instance()->SendRefreshAppList(fake_apps());
280 298
281 // Simulate item activate. 299 // Simulate item activate.
282 const arc::AppInfo& app_first = fake_apps()[0]; 300 const arc::AppInfo& app_first = fake_apps()[0];
283 const arc::AppInfo& app_last = fake_apps()[0]; 301 const arc::AppInfo& app_last = fake_apps()[0];
284 ArcAppItem* item_first = FindArcItem(GetAppId(app_first)); 302 ArcAppItem* item_first = FindArcItem(GetAppId(app_first));
285 ArcAppItem* item_last = FindArcItem(GetAppId(app_last)); 303 ArcAppItem* item_last = FindArcItem(GetAppId(app_last));
286 ASSERT_NE(nullptr, item_first); 304 ASSERT_NE(nullptr, item_first);
287 ASSERT_NE(nullptr, item_last); 305 ASSERT_NE(nullptr, item_last);
288 item_first->Activate(0); 306 item_first->Activate(0);
307 app_instance()->WaitForIncomingMethodCall();
289 item_last->Activate(0); 308 item_last->Activate(0);
309 app_instance()->WaitForIncomingMethodCall();
290 item_first->Activate(0); 310 item_first->Activate(0);
311 app_instance()->WaitForIncomingMethodCall();
291 312
292 const ScopedVector<arc::FakeArcBridgeService::Request>& launch_requests = 313 const ScopedVector<arc::FakeAppInstance::Request>& launch_requests =
293 bridge_service()->launch_requests(); 314 app_instance()->launch_requests();
294 EXPECT_EQ(static_cast<size_t>(3), launch_requests.size()); 315 ASSERT_EQ(static_cast<size_t>(3), launch_requests.size());
295 EXPECT_EQ(true, launch_requests[0]->IsForApp(app_first)); 316 EXPECT_EQ(true, launch_requests[0]->IsForApp(app_first));
296 EXPECT_EQ(true, launch_requests[1]->IsForApp(app_last)); 317 EXPECT_EQ(true, launch_requests[1]->IsForApp(app_last));
297 EXPECT_EQ(true, launch_requests[2]->IsForApp(app_first)); 318 EXPECT_EQ(true, launch_requests[2]->IsForApp(app_first));
298 319
299 // Test an attempt to launch of a not-ready app. 320 // Test an attempt to launch of a not-ready app.
300 bridge_service()->SendRefreshAppList(std::vector<arc::AppInfo>()); 321 app_instance()->SendRefreshAppList(std::vector<arc::AppInfo>());
301 item_first = FindArcItem(GetAppId(app_first)); 322 item_first = FindArcItem(GetAppId(app_first));
302 ASSERT_NE(nullptr, item_first); 323 ASSERT_NE(nullptr, item_first);
303 size_t launch_request_count_before = 324 size_t launch_request_count_before = app_instance()->launch_requests().size();
304 bridge_service()->launch_requests().size();
305 item_first->Activate(0); 325 item_first->Activate(0);
306 // Number of launch requests must not change. 326 // Number of launch requests must not change.
307 EXPECT_EQ(launch_request_count_before, 327 EXPECT_EQ(launch_request_count_before,
308 bridge_service()->launch_requests().size()); 328 app_instance()->launch_requests().size());
309 } 329 }
310 330
311 TEST_F(ArcAppModelBuilderTest, RequestIcons) { 331 TEST_F(ArcAppModelBuilderTest, RequestIcons) {
312 // Make sure we are on UI thread. 332 // Make sure we are on UI thread.
313 ASSERT_EQ(true, 333 ASSERT_EQ(true,
314 content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 334 content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
315 335
316 bridge_service()->SetReady(); 336 bridge_service()->SetReady();
317 bridge_service()->SendRefreshAppList(fake_apps()); 337 app_instance()->RefreshAppList();
338 app_instance()->SendRefreshAppList(fake_apps());
318 339
319 // Validate that no icon exists at the beginning and request icon for 340 // Validate that no icon exists at the beginning and request icon for
320 // each supported scale factor. This will start asynchronous loading. 341 // each supported scale factor. This will start asynchronous loading.
321 uint32_t expected_mask = 0; 342 uint32_t expected_mask = 0;
322 const std::vector<ui::ScaleFactor>& scale_factors = 343 const std::vector<ui::ScaleFactor>& scale_factors =
323 ui::GetSupportedScaleFactors(); 344 ui::GetSupportedScaleFactors();
324 for (auto& scale_factor : scale_factors) { 345 for (auto& scale_factor : scale_factors) {
325 expected_mask |= 1 << scale_factor; 346 expected_mask |= 1 << scale_factor;
326 for (auto& app : fake_apps()) { 347 for (auto& app : fake_apps()) {
327 ArcAppItem* app_item = FindArcItem(GetAppId(app)); 348 ArcAppItem* app_item = FindArcItem(GetAppId(app));
328 ASSERT_NE(nullptr, app_item); 349 ASSERT_NE(nullptr, app_item);
329 const float scale = ui::GetScaleForScaleFactor(scale_factor); 350 const float scale = ui::GetScaleForScaleFactor(scale_factor);
330 app_item->icon().GetRepresentation(scale); 351 app_item->icon().GetRepresentation(scale);
331 } 352 }
332 } 353 }
333 354
334 // Process pending tasks. 355 // Process pending tasks.
335 content::BrowserThread::GetBlockingPool()->FlushForTesting(); 356 content::BrowserThread::GetBlockingPool()->FlushForTesting();
336 base::RunLoop().RunUntilIdle(); 357 base::RunLoop().RunUntilIdle();
358 // Normally just one call to RunUntilIdle() suffices to make sure
359 // all RequestAppIcon() calls are delivered, but on slower machines
360 // (especially when running under Valgrind), they might not get
361 // delivered on time. Wait for the remaining tasks individually.
362 const size_t expected_size = scale_factors.size() * fake_apps().size();
363 while (app_instance()->icon_requests().size() < expected_size) {
364 app_instance()->WaitForIncomingMethodCall();
365 }
337 366
338 // At this moment we should receive all requests for icon loading. 367 // At this moment we should receive all requests for icon loading.
339 const ScopedVector<arc::FakeArcBridgeService::IconRequest>& icon_requests = 368 const ScopedVector<arc::FakeAppInstance::IconRequest>& icon_requests =
340 bridge_service()->icon_requests(); 369 app_instance()->icon_requests();
341 EXPECT_EQ(scale_factors.size() * fake_apps().size(), icon_requests.size()); 370 EXPECT_EQ(expected_size, icon_requests.size());
342 std::map<std::string, uint32_t> app_masks; 371 std::map<std::string, uint32_t> app_masks;
343 for (size_t i = 0; i < icon_requests.size(); ++i) { 372 for (size_t i = 0; i < icon_requests.size(); ++i) {
344 const arc::FakeArcBridgeService::IconRequest* icon_request = 373 const arc::FakeAppInstance::IconRequest* icon_request = icon_requests[i];
345 icon_requests[i];
346 const std::string id = ArcAppListPrefs::GetAppId(icon_request->package(), 374 const std::string id = ArcAppListPrefs::GetAppId(icon_request->package(),
347 icon_request->activity()); 375 icon_request->activity());
348 // Make sure no double requests. 376 // Make sure no double requests.
349 EXPECT_NE(app_masks[id], 377 EXPECT_NE(app_masks[id],
350 app_masks[id] | (1 << icon_request->scale_factor())); 378 app_masks[id] | (1 << icon_request->scale_factor()));
351 app_masks[id] |= (1 << icon_request->scale_factor()); 379 app_masks[id] |= (1 << icon_request->scale_factor());
352 } 380 }
353 381
354 // Validate that we have a request for each icon for each supported scale 382 // Validate that we have a request for each icon for each supported scale
355 // factor. 383 // factor.
356 EXPECT_EQ(fake_apps().size(), app_masks.size()); 384 EXPECT_EQ(fake_apps().size(), app_masks.size());
357 for (auto& app : fake_apps()) { 385 for (auto& app : fake_apps()) {
358 const std::string id = GetAppId(app); 386 const std::string id = GetAppId(app);
359 ASSERT_NE(app_masks.find(id), app_masks.end()); 387 ASSERT_NE(app_masks.find(id), app_masks.end());
360 EXPECT_EQ(app_masks[id], expected_mask); 388 EXPECT_EQ(app_masks[id], expected_mask);
361 } 389 }
362 } 390 }
363 391
364 TEST_F(ArcAppModelBuilderTest, InstallIcon) { 392 TEST_F(ArcAppModelBuilderTest, InstallIcon) {
365 // Make sure we are on UI thread. 393 // Make sure we are on UI thread.
366 ASSERT_EQ(true, 394 ASSERT_EQ(true,
367 content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 395 content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
368 396
369 397
370 bridge_service()->SetReady(); 398 bridge_service()->SetReady();
371 bridge_service()->SendRefreshAppList(std::vector<arc::AppInfo>( 399 app_instance()->RefreshAppList();
372 fake_apps().begin(), fake_apps().begin() + 1)); 400 app_instance()->SendRefreshAppList(
401 std::vector<arc::AppInfo>(fake_apps().begin(), fake_apps().begin() + 1));
373 const arc::AppInfo& app = fake_apps()[0]; 402 const arc::AppInfo& app = fake_apps()[0];
374 403
375 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); 404 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get());
376 ASSERT_NE(nullptr, prefs); 405 ASSERT_NE(nullptr, prefs);
377 406
378 const ui::ScaleFactor scale_factor = ui::GetSupportedScaleFactors()[0]; 407 const ui::ScaleFactor scale_factor = ui::GetSupportedScaleFactors()[0];
379 const float scale = ui::GetScaleForScaleFactor(scale_factor); 408 const float scale = ui::GetScaleForScaleFactor(scale_factor);
380 const base::FilePath icon_path = prefs->GetIconPath(GetAppId(app), 409 const base::FilePath icon_path = prefs->GetIconPath(GetAppId(app),
381 scale_factor); 410 scale_factor);
382 EXPECT_EQ(true, !base::PathExists(icon_path)); 411 EXPECT_EQ(true, !base::PathExists(icon_path));
383 412
384 const ArcAppItem* app_item = FindArcItem(GetAppId(app)); 413 const ArcAppItem* app_item = FindArcItem(GetAppId(app));
385 EXPECT_NE(nullptr, app_item); 414 EXPECT_NE(nullptr, app_item);
386 // This initiates async loading. 415 // This initiates async loading.
387 app_item->icon().GetRepresentation(scale); 416 app_item->icon().GetRepresentation(scale);
388 417
389 // Process pending tasks. 418 // Process pending tasks.
390 content::BrowserThread::GetBlockingPool()->FlushForTesting(); 419 content::BrowserThread::GetBlockingPool()->FlushForTesting();
391 base::RunLoop().RunUntilIdle(); 420 base::RunLoop().RunUntilIdle();
392 421
393 // Validating decoded content does not fit well for unit tests. 422 // Validating decoded content does not fit well for unit tests.
394 ArcAppIcon::DisableDecodingForTesting(); 423 ArcAppIcon::DisableDecodingForTesting();
395 424
396 // Now send generated icon for the app. 425 // Now send generated icon for the app.
397 std::string png_data; 426 std::string png_data;
398 EXPECT_EQ(true, bridge_service()->GenerateAndSendIcon( 427 EXPECT_EQ(true,
399 app, 428 app_instance()->GenerateAndSendIcon(
400 static_cast<arc::ScaleFactor>(scale_factor), 429 app, static_cast<arc::ScaleFactor>(scale_factor), &png_data));
401 &png_data));
402 430
403 // Process pending tasks. 431 // Process pending tasks.
404 content::BrowserThread::GetBlockingPool()->FlushForTesting(); 432 content::BrowserThread::GetBlockingPool()->FlushForTesting();
405 base::RunLoop().RunUntilIdle(); 433 base::RunLoop().RunUntilIdle();
406 434
407 // Validate that icons are installed, have right content and icon is 435 // Validate that icons are installed, have right content and icon is
408 // refreshed for ARC app item. 436 // refreshed for ARC app item.
409 EXPECT_EQ(true, base::PathExists(icon_path)); 437 EXPECT_EQ(true, base::PathExists(icon_path));
410 438
411 std::string icon_data; 439 std::string icon_data;
412 // Read the file from disk and compare with reference data. 440 // Read the file from disk and compare with reference data.
413 EXPECT_EQ(true, base::ReadFileToString(icon_path, &icon_data)); 441 EXPECT_EQ(true, base::ReadFileToString(icon_path, &icon_data));
414 ASSERT_EQ(icon_data, png_data); 442 ASSERT_EQ(icon_data, png_data);
415 } 443 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc ('k') | components/arc.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698