OLD | NEW |
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 Loading... |
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 Loading... |
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 ArcAppWindow::DisableSafeIconDecodingForTesting(); |
| 2298 |
| 2299 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); |
| 2300 SendListOfArcApps(); |
| 2301 |
| 2302 std::string png_data; |
| 2303 EXPECT_TRUE(arc_test_.app_instance()->GenerateAndSendIcon( |
| 2304 arc_test_.fake_apps()[0], arc::mojom::ScaleFactor::SCALE_FACTOR_300P, |
| 2305 &png_data)); |
| 2306 EXPECT_FALSE(png_data.empty()); |
| 2307 std::string invalid_png_data("aaaaaa"); |
| 2308 |
| 2309 EXPECT_FALSE(launcher_controller_->GetItem(ash::ShelfID(arc_app_id))); |
| 2310 std::string window_app_id1("org.chromium.arc.1"); |
| 2311 std::string window_app_id2("org.chromium.arc.2"); |
| 2312 views::Widget* window1 = CreateArcWindow(window_app_id1); |
| 2313 ASSERT_TRUE(window1 && window1->GetNativeWindow()); |
| 2314 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0], |
| 2315 std::string()); |
| 2316 |
| 2317 views::Widget* window2 = CreateArcWindow(window_app_id2); |
| 2318 ASSERT_TRUE(window2 && window2->GetNativeWindow()); |
| 2319 arc_test_.app_instance()->SendTaskCreated(2, arc_test_.fake_apps()[0], |
| 2320 std::string()); |
| 2321 EXPECT_TRUE(launcher_controller_->GetItem(ash::ShelfID(arc_app_id))); |
| 2322 ash::ShelfItemDelegate* item_delegate = |
| 2323 model_->GetShelfItemDelegate(ash::ShelfID(arc_app_id)); |
| 2324 ASSERT_TRUE(item_delegate); |
| 2325 |
| 2326 // No custom icon set. Acitivating windows should not change icon. |
| 2327 EXPECT_FALSE(item_delegate->image_set_by_controller()); |
| 2328 window1->Activate(); |
| 2329 EXPECT_FALSE(item_delegate->image_set_by_controller()); |
| 2330 window2->Activate(); |
| 2331 EXPECT_FALSE(item_delegate->image_set_by_controller()); |
| 2332 |
| 2333 // Set custom icon on active item. Icon should be change to custom. |
| 2334 exo::ShellSurface::SetUnsafeIconPngData(window2->GetNativeWindow(), |
| 2335 &png_data); |
| 2336 EXPECT_TRUE(item_delegate->image_set_by_controller()); |
| 2337 |
| 2338 // Switch back to the item without custom icon. Icon should be changed to |
| 2339 // default. |
| 2340 window1->Activate(); |
| 2341 EXPECT_FALSE(item_delegate->image_set_by_controller()); |
| 2342 // Test that setting of invalid icon resets the custom icon. |
| 2343 exo::ShellSurface::SetUnsafeIconPngData(window1->GetNativeWindow(), |
| 2344 &png_data); |
| 2345 EXPECT_TRUE(item_delegate->image_set_by_controller()); |
| 2346 exo::ShellSurface::SetUnsafeIconPngData(window1->GetNativeWindow(), |
| 2347 &invalid_png_data); |
| 2348 EXPECT_FALSE(item_delegate->image_set_by_controller()); |
| 2349 |
| 2350 // Check window removing with active custom icon. |
| 2351 exo::ShellSurface::SetUnsafeIconPngData(window1->GetNativeWindow(), |
| 2352 &png_data); |
| 2353 EXPECT_TRUE(item_delegate->image_set_by_controller()); |
| 2354 // Reseting custom icon of inactive window doesn't reset shefl icon. |
| 2355 exo::ShellSurface::SetUnsafeIconPngData(window2->GetNativeWindow(), nullptr); |
| 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 Loading... |
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 } |
OLD | NEW |