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

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

Issue 2773493002: [Merge M58] arc: Fix regression in handling ARC shelf item. (Closed)
Patch Set: resolve merge conflicts and adopt to M58 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 #include "extensions/browser/app_window/native_app_window.h" 103 #include "extensions/browser/app_window/native_app_window.h"
104 #include "extensions/common/extension.h" 104 #include "extensions/common/extension.h"
105 #include "extensions/common/manifest_constants.h" 105 #include "extensions/common/manifest_constants.h"
106 #include "testing/gtest/include/gtest/gtest.h" 106 #include "testing/gtest/include/gtest/gtest.h"
107 #include "ui/aura/client/window_parenting_client.h" 107 #include "ui/aura/client/window_parenting_client.h"
108 #include "ui/aura/window.h" 108 #include "ui/aura/window.h"
109 #include "ui/base/models/menu_model.h" 109 #include "ui/base/models/menu_model.h"
110 #include "ui/display/display.h" 110 #include "ui/display/display.h"
111 #include "ui/display/display_switches.h" 111 #include "ui/display/display_switches.h"
112 #include "ui/display/screen.h" 112 #include "ui/display/screen.h"
113 #include "ui/events/base_event_utils.h"
113 #include "ui/events/event_constants.h" 114 #include "ui/events/event_constants.h"
114 #include "ui/views/widget/widget.h" 115 #include "ui/views/widget/widget.h"
115 116
116 using base::ASCIIToUTF16; 117 using base::ASCIIToUTF16;
117 using extensions::Extension; 118 using extensions::Extension;
118 using extensions::Manifest; 119 using extensions::Manifest;
119 using extensions::UnloadedExtensionInfo; 120 using extensions::UnloadedExtensionInfo;
120 using arc::mojom::OrientationLock; 121 using arc::mojom::OrientationLock;
121 122
122 namespace { 123 namespace {
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 void UnpinAppWithID(const std::string& app_id) override { 322 void UnpinAppWithID(const std::string& app_id) override {
322 return controller_->UnpinAppWithID(app_id); 323 return controller_->UnpinAppWithID(app_id);
323 } 324 }
324 325
325 private: 326 private:
326 ChromeLauncherControllerImpl* const controller_; 327 ChromeLauncherControllerImpl* const controller_;
327 328
328 DISALLOW_COPY_AND_ASSIGN(ProxyShelfDelegate); 329 DISALLOW_COPY_AND_ASSIGN(ProxyShelfDelegate);
329 }; 330 };
330 331
332 // Simulates selection of the shelf item.
333 void SelectItem(LauncherItemController* delegate) {
334 delegate->ItemSelected(ui::ET_MOUSE_PRESSED, ui::EF_NONE,
335 display::kInvalidDisplayId, ash::LAUNCH_FROM_UNKNOWN);
336 }
337
331 } // namespace 338 } // namespace
332 339
333 class ChromeLauncherControllerImplTest : public BrowserWithTestWindowTest { 340 class ChromeLauncherControllerImplTest : public BrowserWithTestWindowTest {
334 protected: 341 protected:
335 ChromeLauncherControllerImplTest() 342 ChromeLauncherControllerImplTest()
336 : BrowserWithTestWindowTest(Browser::TYPE_TABBED, false) {} 343 : BrowserWithTestWindowTest(Browser::TYPE_TABBED, false) {}
337 344
338 ~ChromeLauncherControllerImplTest() override {} 345 ~ChromeLauncherControllerImplTest() override {}
339 346
340 void SetUp() override { 347 void SetUp() override {
(...skipping 3391 matching lines...) Expand 10 before | Expand all | Expand 10 after
3732 ValidateArcState(false, false, arc::ArcSessionManager::State::STOPPED, 3739 ValidateArcState(false, false, arc::ArcSessionManager::State::STOPPED,
3733 "AppList, Chrome"); 3740 "AppList, Chrome");
3734 3741
3735 // Even if re-enable it again, Play Store pin does not appear automatically. 3742 // Even if re-enable it again, Play Store pin does not appear automatically.
3736 EnableArc(true); 3743 EnableArc(true);
3737 ValidateArcState(true, false, 3744 ValidateArcState(true, false,
3738 arc::ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, 3745 arc::ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE,
3739 "AppList, Chrome"); 3746 "AppList, Chrome");
3740 } 3747 }
3741 3748
3749 // Test the application menu of a shelf item with multiple ARC windows.
3750 TEST_F(ChromeLauncherControllerImplWithArcTest, ShelfItemWithMultipleWindows) {
3751 InitLauncherControllerWithBrowser();
3752
3753 arc::mojom::AppInfo appinfo =
3754 CreateAppInfo("Test1", "test", "com.example.app", OrientationLock::NONE);
3755 AddArcAppAndShortcut(appinfo);
3756
3757 // Widgets will be deleted by the system.
3758 NotifyOnTaskCreated(appinfo, 1 /* task_id */);
3759 views::Widget* window1 = CreateArcWindow("org.chromium.arc.1");
3760 ASSERT_TRUE(window1);
3761 EXPECT_TRUE(window1->IsActive());
3762
3763 NotifyOnTaskCreated(appinfo, 2 /* task_id */);
3764 views::Widget* window2 = CreateArcWindow("org.chromium.arc.2");
3765 ASSERT_TRUE(window2);
3766
3767 EXPECT_FALSE(window1->IsActive());
3768 EXPECT_TRUE(window2->IsActive());
3769
3770 const std::string app_id = ArcAppTest::GetAppId(appinfo);
3771
3772 const ash::ShelfID shelf_id =
3773 launcher_controller_->GetShelfIDForAppID(app_id);
3774 LauncherItemController* item_controller =
3775 launcher_controller_->GetLauncherItemController(shelf_id);
3776 ASSERT_TRUE(item_controller);
3777
3778 // Selecting the item will show its application menu. It does not change the
3779 // active window.
3780 SelectItem(item_controller);
3781 EXPECT_FALSE(window1->IsActive());
3782 EXPECT_TRUE(window2->IsActive());
3783
3784 // Command ids are just app window indices. Note, apps are registered in
3785 // opposite order. Last created goes in front.
3786 ash::ShelfAppMenuItemList items = item_controller->GetAppMenuItems(0);
3787 ASSERT_EQ(items.size(), 2U);
3788 EXPECT_EQ(items[0]->command_id(), 0U);
3789 EXPECT_EQ(items[1]->command_id(), 1U);
3790
3791 // Execute command to activate first window.
3792 item_controller->ExecuteCommand(items[1]->command_id(), 0);
3793 EXPECT_TRUE(window1->IsActive());
3794 EXPECT_FALSE(window2->IsActive());
3795
3796 // Selecting the item will show its application menu. It does not change the
3797 // active window.
3798 SelectItem(item_controller);
3799 EXPECT_TRUE(window1->IsActive());
3800 EXPECT_FALSE(window2->IsActive());
3801
3802 // Execute command to activate second window.
3803 item_controller->ExecuteCommand(items[0]->command_id(), 0);
3804 EXPECT_FALSE(window1->IsActive());
3805 EXPECT_TRUE(window2->IsActive());
3806 }
3807
3742 namespace { 3808 namespace {
3743 3809
3744 class ChromeLauncherControllerOrientationTest 3810 class ChromeLauncherControllerOrientationTest
3745 : public ChromeLauncherControllerImplWithArcTest { 3811 : public ChromeLauncherControllerImplWithArcTest {
3746 public: 3812 public:
3747 ChromeLauncherControllerOrientationTest() {} 3813 ChromeLauncherControllerOrientationTest() {}
3748 ~ChromeLauncherControllerOrientationTest() override {} 3814 ~ChromeLauncherControllerOrientationTest() override {}
3749 3815
3750 protected: 3816 protected:
3751 void InitApps() { 3817 void InitApps() {
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
4306 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, 4372 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
4307 shelf_controller->auto_hide()); 4373 shelf_controller->auto_hide());
4308 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count()); 4374 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count());
4309 4375
4310 PrefService* prefs = profile()->GetTestingPrefService(); 4376 PrefService* prefs = profile()->GetTestingPrefService();
4311 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal)); 4377 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal));
4312 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment)); 4378 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment));
4313 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal)); 4379 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal));
4314 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior)); 4380 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior));
4315 } 4381 }
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