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

Side by Side Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller_unittest.cc

Issue 2894443002: arc: Set custom icon in shelf for ARC apps. (Closed)
Patch Set: rebase Created 3 years, 7 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #include "chrome/browser/prefs/browser_prefs.h" 51 #include "chrome/browser/prefs/browser_prefs.h"
52 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" 52 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h"
53 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" 53 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
54 #include "chrome/browser/ui/app_list/arc/arc_app_test.h" 54 #include "chrome/browser/ui/app_list/arc/arc_app_test.h"
55 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" 55 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
56 #include "chrome/browser/ui/app_list/arc/arc_default_app_list.h" 56 #include "chrome/browser/ui/app_list/arc/arc_default_app_list.h"
57 #include "chrome/browser/ui/apps/chrome_app_delegate.h" 57 #include "chrome/browser/ui/apps/chrome_app_delegate.h"
58 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" 58 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h"
59 #include "chrome/browser/ui/ash/launcher/app_window_launcher_controller.h" 59 #include "chrome/browser/ui/ash/launcher/app_window_launcher_controller.h"
60 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h" 60 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h"
61 #include "chrome/browser/ui/ash/launcher/arc_app_window.h"
62 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h"
61 #include "chrome/browser/ui/ash/launcher/browser_status_monitor.h" 63 #include "chrome/browser/ui/ash/launcher/browser_status_monitor.h"
62 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h" 64 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h"
63 #include "chrome/browser/ui/ash/launcher/extension_app_window_launcher_item_cont roller.h" 65 #include "chrome/browser/ui/ash/launcher/extension_app_window_launcher_item_cont roller.h"
64 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" 66 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h"
65 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" 67 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
66 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" 68 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h"
67 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h" 69 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h"
68 #include "chrome/browser/ui/browser.h" 70 #include "chrome/browser/ui/browser.h"
69 #include "chrome/browser/ui/browser_commands.h" 71 #include "chrome/browser/ui/browser_commands.h"
70 #include "chrome/browser/ui/browser_finder.h" 72 #include "chrome/browser/ui/browser_finder.h"
(...skipping 2210 matching lines...) Expand 10 before | Expand all | Expand 10 after
2281 2283
2282 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); 2284 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
2283 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id1)); 2285 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id1));
2284 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); 2286 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id()));
2285 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id2)); 2287 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id2));
2286 2288
2287 EXPECT_EQ("AppList, Chrome, App1, Fake App 1, App2, Fake App 0", 2289 EXPECT_EQ("AppList, Chrome, App1, Fake App 1, App2, Fake App 0",
2288 GetPinnedAppStatus()); 2290 GetPinnedAppStatus());
2289 } 2291 }
2290 2292
2293 TEST_P(ChromeLauncherControllerWithArcTest, ArcCustomAppIcon) {
2294 InitLauncherController();
2295
2296 ArcAppIcon::DisableSafeDecodingForTesting();
2297
2298 // Register fake ARC apps.
2299 SendListOfArcApps();
2300 // Use first fake ARC app for testing.
2301 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
2302
2303 // Generate icon for the testing app and use compressed png content as test
2304 // input.
2305 std::string png_data;
2306 EXPECT_TRUE(arc_test_.app_instance()->GenerateAndSendIcon(
2307 arc_test_.fake_apps()[0], arc::mojom::ScaleFactor::SCALE_FACTOR_300P,
2308 &png_data));
2309 EXPECT_FALSE(png_data.empty());
2310 // Some input that represents invalid png content.
2311 std::string invalid_png_data("aaaaaa");
2312
2313 EXPECT_FALSE(launcher_controller_->GetItem(ash::ShelfID(arc_app_id)));
2314 std::string window_app_id1("org.chromium.arc.1");
2315 std::string window_app_id2("org.chromium.arc.2");
2316 views::Widget* window1 = CreateArcWindow(window_app_id1);
2317 ASSERT_TRUE(window1 && window1->GetNativeWindow());
2318 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0],
2319 std::string());
2320
2321 views::Widget* window2 = CreateArcWindow(window_app_id2);
2322 ASSERT_TRUE(window2 && window2->GetNativeWindow());
2323 arc_test_.app_instance()->SendTaskCreated(2, arc_test_.fake_apps()[0],
2324 std::string());
2325 EXPECT_TRUE(launcher_controller_->GetItem(ash::ShelfID(arc_app_id)));
2326 ash::ShelfItemDelegate* item_delegate =
2327 model_->GetShelfItemDelegate(ash::ShelfID(arc_app_id));
2328 ASSERT_TRUE(item_delegate);
2329
2330 // No custom icon set. Acitivating windows should not change icon.
2331 EXPECT_FALSE(item_delegate->image_set_by_controller());
2332 window1->Activate();
2333 EXPECT_FALSE(item_delegate->image_set_by_controller());
2334 window2->Activate();
2335 EXPECT_FALSE(item_delegate->image_set_by_controller());
2336
2337 // Set custom icon on active item. Icon should change to custom.
2338 arc_test_.app_instance()->SendTaskDescription(2, std::string(), png_data);
2339 EXPECT_TRUE(item_delegate->image_set_by_controller());
2340
2341 // Switch back to the item without custom icon. Icon should be changed to
2342 // default.
2343 window1->Activate();
2344 EXPECT_FALSE(item_delegate->image_set_by_controller());
2345 // Test that setting an invalid icon should not change custom icon.
2346 arc_test_.app_instance()->SendTaskDescription(1, std::string(), png_data);
2347 EXPECT_TRUE(item_delegate->image_set_by_controller());
2348 arc_test_.app_instance()->SendTaskDescription(1, std::string(),
2349 invalid_png_data);
2350 EXPECT_TRUE(item_delegate->image_set_by_controller());
2351
2352 // Check window removing with active custom icon. Reseting custom icon of
2353 // inactive window doesn't reset shelf icon.
2354 arc_test_.app_instance()->SendTaskDescription(2, std::string(),
2355 std::string());
2356 EXPECT_TRUE(item_delegate->image_set_by_controller());
2357 window1->CloseNow();
2358 EXPECT_FALSE(item_delegate->image_set_by_controller());
2359 }
2360
2291 // Check that with multi profile V1 apps are properly added / removed from the 2361 // Check that with multi profile V1 apps are properly added / removed from the
2292 // shelf. 2362 // shelf.
2293 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, 2363 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest,
2294 V1AppUpdateOnUserSwitch) { 2364 V1AppUpdateOnUserSwitch) {
2295 // Create a browser item in the LauncherController. 2365 // Create a browser item in the LauncherController.
2296 InitLauncherController(); 2366 InitLauncherController();
2297 2367
2298 EXPECT_EQ(2, model_->item_count()); 2368 EXPECT_EQ(2, model_->item_count());
2299 { 2369 {
2300 // Create a "windowed gmail app". 2370 // Create a "windowed gmail app".
(...skipping 1914 matching lines...) Expand 10 before | Expand all | Expand 10 after
4215 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, 4285 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
4216 shelf_controller->auto_hide()); 4286 shelf_controller->auto_hide());
4217 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count()); 4287 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count());
4218 4288
4219 PrefService* prefs = profile()->GetTestingPrefService(); 4289 PrefService* prefs = profile()->GetTestingPrefService();
4220 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal)); 4290 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal));
4221 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment)); 4291 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment));
4222 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal)); 4292 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal));
4223 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior)); 4293 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior));
4224 } 4294 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/launcher/arc_app_window_launcher_item_controller.cc ('k') | components/arc/common/app.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698