Chromium Code Reviews| 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(); | |
|
msw
2017/05/18 18:27:00
Would it be reasonable for ArcAppWindow to check t
khmel
2017/05/18 20:27:52
Added getter to ArcAppIcon
| |
| 2298 | |
| 2299 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); | |
| 2300 SendListOfArcApps(); | |
| 2301 | |
| 2302 std::string png_data; | |
|
msw
2017/05/18 18:27:00
nit: add more comments to explain what these first
khmel
2017/05/18 20:27:52
Done.
| |
| 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. | |
|
msw
2017/05/18 18:27:00
nit: 'be changed' or just 'should change'
khmel
2017/05/18 20:27:52
Done.
| |
| 2334 arc_test_.app_instance()->SendTaskDescription(2, std::string(), png_data); | |
| 2335 EXPECT_TRUE(item_delegate->image_set_by_controller()); | |
| 2336 | |
| 2337 // Switch back to the item without custom icon. Icon should be changed to | |
| 2338 // default. | |
| 2339 window1->Activate(); | |
| 2340 EXPECT_FALSE(item_delegate->image_set_by_controller()); | |
| 2341 // Test that setting of invalid icon resets the custom icon. | |
|
msw
2017/05/18 18:27:00
nit: 'setting an'
khmel
2017/05/18 20:27:52
Done.
| |
| 2342 arc_test_.app_instance()->SendTaskDescription(1, std::string(), png_data); | |
| 2343 EXPECT_TRUE(item_delegate->image_set_by_controller()); | |
| 2344 arc_test_.app_instance()->SendTaskDescription(1, std::string(), | |
| 2345 invalid_png_data); | |
| 2346 EXPECT_FALSE(item_delegate->image_set_by_controller()); | |
| 2347 | |
| 2348 // Check window removing with active custom icon. | |
|
msw
2017/05/18 18:27:00
nit: move comment down to where you're actually re
khmel
2017/05/18 20:27:52
Done.
| |
| 2349 arc_test_.app_instance()->SendTaskDescription(1, std::string(), png_data); | |
| 2350 EXPECT_TRUE(item_delegate->image_set_by_controller()); | |
| 2351 // Reseting custom icon of inactive window doesn't reset shefl icon. | |
|
msw
2017/05/18 18:27:00
nit: "shelf"
khmel
2017/05/18 20:27:52
Done.
| |
| 2352 arc_test_.app_instance()->SendTaskDescription(2, std::string(), | |
| 2353 std::string()); | |
| 2354 EXPECT_TRUE(item_delegate->image_set_by_controller()); | |
| 2355 window1->CloseNow(); | |
| 2356 EXPECT_FALSE(item_delegate->image_set_by_controller()); | |
| 2357 } | |
| 2358 | |
| 2291 // Check that with multi profile V1 apps are properly added / removed from the | 2359 // Check that with multi profile V1 apps are properly added / removed from the |
| 2292 // shelf. | 2360 // shelf. |
| 2293 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, | 2361 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, |
| 2294 V1AppUpdateOnUserSwitch) { | 2362 V1AppUpdateOnUserSwitch) { |
| 2295 // Create a browser item in the LauncherController. | 2363 // Create a browser item in the LauncherController. |
| 2296 InitLauncherController(); | 2364 InitLauncherController(); |
| 2297 | 2365 |
| 2298 EXPECT_EQ(2, model_->item_count()); | 2366 EXPECT_EQ(2, model_->item_count()); |
| 2299 { | 2367 { |
| 2300 // Create a "windowed gmail app". | 2368 // 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, | 4283 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, |
| 4216 shelf_controller->auto_hide()); | 4284 shelf_controller->auto_hide()); |
| 4217 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count()); | 4285 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count()); |
| 4218 | 4286 |
| 4219 PrefService* prefs = profile()->GetTestingPrefService(); | 4287 PrefService* prefs = profile()->GetTestingPrefService(); |
| 4220 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal)); | 4288 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal)); |
| 4221 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment)); | 4289 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment)); |
| 4222 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal)); | 4290 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal)); |
| 4223 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior)); | 4291 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior)); |
| 4224 } | 4292 } |
| OLD | NEW |