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

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

Issue 2763893004: arc: Fix regression in handling ARC shelf item. (Closed)
Patch Set: comments updated Created 3 years, 9 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 | « chrome/browser/ui/ash/launcher/arc_app_window_launcher_item_controller.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_impl.h" 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 #include "extensions/browser/app_window/native_app_window.h" 104 #include "extensions/browser/app_window/native_app_window.h"
105 #include "extensions/common/extension.h" 105 #include "extensions/common/extension.h"
106 #include "extensions/common/manifest_constants.h" 106 #include "extensions/common/manifest_constants.h"
107 #include "testing/gtest/include/gtest/gtest.h" 107 #include "testing/gtest/include/gtest/gtest.h"
108 #include "ui/aura/client/window_parenting_client.h" 108 #include "ui/aura/client/window_parenting_client.h"
109 #include "ui/aura/window.h" 109 #include "ui/aura/window.h"
110 #include "ui/base/models/menu_model.h" 110 #include "ui/base/models/menu_model.h"
111 #include "ui/display/display.h" 111 #include "ui/display/display.h"
112 #include "ui/display/display_switches.h" 112 #include "ui/display/display_switches.h"
113 #include "ui/display/screen.h" 113 #include "ui/display/screen.h"
114 #include "ui/events/base_event_utils.h"
114 #include "ui/events/event_constants.h" 115 #include "ui/events/event_constants.h"
115 #include "ui/views/widget/widget.h" 116 #include "ui/views/widget/widget.h"
116 117
117 using base::ASCIIToUTF16; 118 using base::ASCIIToUTF16;
118 using extensions::Extension; 119 using extensions::Extension;
119 using extensions::Manifest; 120 using extensions::Manifest;
120 using extensions::UnloadedExtensionInfo; 121 using extensions::UnloadedExtensionInfo;
121 using arc::mojom::OrientationLock; 122 using arc::mojom::OrientationLock;
122 123
123 namespace { 124 namespace {
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 void UnpinAppWithID(const std::string& app_id) override { 316 void UnpinAppWithID(const std::string& app_id) override {
316 return controller_->UnpinAppWithID(app_id); 317 return controller_->UnpinAppWithID(app_id);
317 } 318 }
318 319
319 private: 320 private:
320 ChromeLauncherControllerImpl* const controller_; 321 ChromeLauncherControllerImpl* const controller_;
321 322
322 DISALLOW_COPY_AND_ASSIGN(ProxyShelfDelegate); 323 DISALLOW_COPY_AND_ASSIGN(ProxyShelfDelegate);
323 }; 324 };
324 325
326 // A callback that does nothing after shelf item selection handling.
327 void NoopCallback(ash::ShelfAction action, base::Optional<MenuItemList>) {}
328
329 // Simulates selection of the shelf item.
330 void SelectItem(ash::mojom::ShelfItemDelegate* delegate) {
331 std::unique_ptr<ui::Event> event = base::MakeUnique<ui::MouseEvent>(
332 ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(),
333 ui::EF_NONE, 0);
334 delegate->ItemSelected(std::move(event), display::kInvalidDisplayId,
335 ash::LAUNCH_FROM_UNKNOWN, base::Bind(&NoopCallback));
336 }
337
325 } // namespace 338 } // namespace
326 339
327 class ChromeLauncherControllerImplTest : public BrowserWithTestWindowTest { 340 class ChromeLauncherControllerImplTest : public BrowserWithTestWindowTest {
328 protected: 341 protected:
329 ChromeLauncherControllerImplTest() 342 ChromeLauncherControllerImplTest()
330 : BrowserWithTestWindowTest(Browser::TYPE_TABBED, false) {} 343 : BrowserWithTestWindowTest(Browser::TYPE_TABBED, false) {}
331 344
332 ~ChromeLauncherControllerImplTest() override {} 345 ~ChromeLauncherControllerImplTest() override {}
333 346
334 void SetUp() override { 347 void SetUp() override {
(...skipping 3431 matching lines...) Expand 10 before | Expand all | Expand 10 after
3766 ValidateArcState(false, false, arc::ArcSessionManager::State::STOPPED, 3779 ValidateArcState(false, false, arc::ArcSessionManager::State::STOPPED,
3767 "AppList, Chrome"); 3780 "AppList, Chrome");
3768 3781
3769 // Even if re-enable it again, Play Store pin does not appear automatically. 3782 // Even if re-enable it again, Play Store pin does not appear automatically.
3770 EnablePlayStore(true); 3783 EnablePlayStore(true);
3771 ValidateArcState(true, false, 3784 ValidateArcState(true, false,
3772 arc::ArcSessionManager::State::NEGOTIATING_TERMS_OF_SERVICE, 3785 arc::ArcSessionManager::State::NEGOTIATING_TERMS_OF_SERVICE,
3773 "AppList, Chrome"); 3786 "AppList, Chrome");
3774 } 3787 }
3775 3788
3789 // Test the application menu of a shelf item with multiple ARC windows.
3790 TEST_P(ChromeLauncherControllerImplWithArcTest, ShelfItemWithMultipleWindows) {
3791 InitLauncherControllerWithBrowser();
3792
3793 arc::mojom::AppInfo appinfo =
3794 CreateAppInfo("Test1", "test", "com.example.app", OrientationLock::NONE);
3795 AddArcAppAndShortcut(appinfo);
3796
3797 // Widgets will be deleted by the system.
3798 NotifyOnTaskCreated(appinfo, 1 /* task_id */);
3799 views::Widget* window1 = CreateArcWindow("org.chromium.arc.1");
3800 ASSERT_TRUE(window1);
3801 EXPECT_TRUE(window1->IsActive());
3802
3803 NotifyOnTaskCreated(appinfo, 2 /* task_id */);
3804 views::Widget* window2 = CreateArcWindow("org.chromium.arc.2");
3805 ASSERT_TRUE(window2);
3806
3807 EXPECT_FALSE(window1->IsActive());
3808 EXPECT_TRUE(window2->IsActive());
3809
3810 const std::string app_id = ArcAppTest::GetAppId(appinfo);
3811
3812 const ash::ShelfID shelf_id =
3813 launcher_controller_->GetShelfIDForAppID(app_id);
3814 LauncherItemController* item_controller =
3815 launcher_controller_->GetLauncherItemController(shelf_id);
3816 ASSERT_TRUE(item_controller);
3817
3818 // Selecting the item will show its application menu. It does not change the
3819 // active window.
3820 SelectItem(item_controller);
3821 EXPECT_FALSE(window1->IsActive());
3822 EXPECT_TRUE(window2->IsActive());
3823
3824 // Command ids are just app window indices. Note, apps are registered in
3825 // opposite order. Last created goes in front.
3826 MenuItemList items = item_controller->GetAppMenuItems(0);
3827 ASSERT_EQ(items.size(), 2U);
3828 EXPECT_EQ(items[0]->command_id, 0U);
3829 EXPECT_EQ(items[1]->command_id, 1U);
3830
3831 // Execute command to activate first window.
3832 item_controller->ExecuteCommand(items[1]->command_id, 0);
3833 EXPECT_TRUE(window1->IsActive());
3834 EXPECT_FALSE(window2->IsActive());
3835
3836 // Selecting the item will show its application menu. It does not change the
3837 // active window.
3838 SelectItem(item_controller);
3839 EXPECT_TRUE(window1->IsActive());
3840 EXPECT_FALSE(window2->IsActive());
3841
3842 // Execute command to activate second window.
3843 item_controller->ExecuteCommand(items[0]->command_id, 0);
3844 EXPECT_FALSE(window1->IsActive());
3845 EXPECT_TRUE(window2->IsActive());
3846 }
3847
3776 namespace { 3848 namespace {
3777 3849
3778 class ChromeLauncherControllerOrientationTest 3850 class ChromeLauncherControllerOrientationTest
3779 : public ChromeLauncherControllerImplWithArcTest { 3851 : public ChromeLauncherControllerImplWithArcTest {
3780 public: 3852 public:
3781 ChromeLauncherControllerOrientationTest() {} 3853 ChromeLauncherControllerOrientationTest() {}
3782 ~ChromeLauncherControllerOrientationTest() override {} 3854 ~ChromeLauncherControllerOrientationTest() override {}
3783 3855
3784 protected: 3856 protected:
3785 void InitApps() { 3857 void InitApps() {
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
4351 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, 4423 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
4352 shelf_controller->auto_hide()); 4424 shelf_controller->auto_hide());
4353 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count()); 4425 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count());
4354 4426
4355 PrefService* prefs = profile()->GetTestingPrefService(); 4427 PrefService* prefs = profile()->GetTestingPrefService();
4356 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal)); 4428 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal));
4357 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment)); 4429 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment));
4358 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal)); 4430 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal));
4359 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior)); 4431 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior));
4360 } 4432 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/launcher/arc_app_window_launcher_item_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698