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

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

Issue 2540713003: Revert of Propagate information about how ARC apps are launched (Closed)
Patch Set: Created 4 years 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_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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 #include "extensions/browser/app_window/native_app_window.h" 98 #include "extensions/browser/app_window/native_app_window.h"
99 #include "extensions/common/extension.h" 99 #include "extensions/common/extension.h"
100 #include "extensions/common/manifest_constants.h" 100 #include "extensions/common/manifest_constants.h"
101 #include "testing/gtest/include/gtest/gtest.h" 101 #include "testing/gtest/include/gtest/gtest.h"
102 #include "ui/aura/client/window_parenting_client.h" 102 #include "ui/aura/client/window_parenting_client.h"
103 #include "ui/aura/window.h" 103 #include "ui/aura/window.h"
104 #include "ui/base/models/menu_model.h" 104 #include "ui/base/models/menu_model.h"
105 #include "ui/display/display.h" 105 #include "ui/display/display.h"
106 #include "ui/display/display_switches.h" 106 #include "ui/display/display_switches.h"
107 #include "ui/display/screen.h" 107 #include "ui/display/screen.h"
108 #include "ui/events/event_constants.h"
109 #include "ui/views/widget/widget.h" 108 #include "ui/views/widget/widget.h"
110 109
111 using base::ASCIIToUTF16; 110 using base::ASCIIToUTF16;
112 using extensions::Extension; 111 using extensions::Extension;
113 using extensions::Manifest; 112 using extensions::Manifest;
114 using extensions::UnloadedExtensionInfo; 113 using extensions::UnloadedExtensionInfo;
115 using arc::mojom::OrientationLock; 114 using arc::mojom::OrientationLock;
116 115
117 namespace { 116 namespace {
118 const char* offline_gmail_url = "https://mail.google.com/mail/mu/u"; 117 const char* offline_gmail_url = "https://mail.google.com/mail/mu/u";
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 bool arc_managed, 813 bool arc_managed,
815 arc::ArcSessionManager::State state, 814 arc::ArcSessionManager::State state,
816 const std::string& pin_status) { 815 const std::string& pin_status) {
817 EXPECT_EQ(arc_managed, arc_test_.arc_session_manager()->IsArcManaged()); 816 EXPECT_EQ(arc_managed, arc_test_.arc_session_manager()->IsArcManaged());
818 EXPECT_EQ(arc_enabled, arc_test_.arc_session_manager()->IsArcEnabled()); 817 EXPECT_EQ(arc_enabled, arc_test_.arc_session_manager()->IsArcEnabled());
819 EXPECT_EQ(state, arc_test_.arc_session_manager()->state()); 818 EXPECT_EQ(state, arc_test_.arc_session_manager()->state());
820 EXPECT_EQ(pin_status, GetPinnedAppStatus()); 819 EXPECT_EQ(pin_status, GetPinnedAppStatus());
821 } 820 }
822 821
823 // Creates app window and set optional Arc application id. 822 // Creates app window and set optional Arc application id.
824 views::Widget* CreateArcWindow(const std::string& window_app_id) { 823 views::Widget* CreateArcWindow(std::string& window_app_id) {
825 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 824 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
826 params.bounds = gfx::Rect(5, 5, 20, 20); 825 params.bounds = gfx::Rect(5, 5, 20, 20);
827 params.context = GetContext(); 826 params.context = GetContext();
828 views::Widget* widget = new views::Widget(); 827 views::Widget* widget = new views::Widget();
829 widget->Init(params); 828 widget->Init(params);
830 // Set Arc id before showing the window to be recognized in 829 // Set Arc id before showing the window to be recognized in
831 // ArcAppWindowLauncherController. 830 // ArcAppWindowLauncherController.
832 exo::ShellSurface::SetApplicationId(widget->GetNativeWindow(), 831 exo::ShellSurface::SetApplicationId(widget->GetNativeWindow(),
833 window_app_id); 832 window_app_id);
834 widget->Show(); 833 widget->Show();
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 1197
1199 ash::test::TestShellDelegate* shell_delegate_; 1198 ash::test::TestShellDelegate* shell_delegate_;
1200 1199
1201 ProfileToNameMap created_profiles_; 1200 ProfileToNameMap created_profiles_;
1202 1201
1203 DISALLOW_COPY_AND_ASSIGN( 1202 DISALLOW_COPY_AND_ASSIGN(
1204 MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest); 1203 MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest);
1205 }; 1204 };
1206 1205
1207 class ChromeLauncherControllerImplMultiProfileWithArcTest 1206 class ChromeLauncherControllerImplMultiProfileWithArcTest
1208 : public MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest { // NOLINT(whitespace/line_length) 1207 : public MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest {
1209 protected: 1208 protected:
1210 ChromeLauncherControllerImplMultiProfileWithArcTest() { 1209 ChromeLauncherControllerImplMultiProfileWithArcTest() {
1211 auto_start_arc_test_ = true; 1210 auto_start_arc_test_ = true;
1212 } 1211 }
1213 ~ChromeLauncherControllerImplMultiProfileWithArcTest() override {} 1212 ~ChromeLauncherControllerImplMultiProfileWithArcTest() override {}
1214 1213
1215 private: 1214 private:
1216 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImplMultiProfileWithArcTest); 1215 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImplMultiProfileWithArcTest);
1217 }; 1216 };
1218 1217
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
1777 1776
1778 arc_test_.StopArcInstance(); 1777 arc_test_.StopArcInstance();
1779 1778
1780 EXPECT_EQ(ash::kInvalidShelfID, 1779 EXPECT_EQ(ash::kInvalidShelfID,
1781 launcher_controller_->GetShelfIDForAppID(arc_app_id1)); 1780 launcher_controller_->GetShelfIDForAppID(arc_app_id1));
1782 EXPECT_EQ(ash::kInvalidShelfID, 1781 EXPECT_EQ(ash::kInvalidShelfID,
1783 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); 1782 launcher_controller_->GetShelfIDForAppID(arc_app_id2));
1784 EXPECT_EQ(ash::kInvalidShelfID, 1783 EXPECT_EQ(ash::kInvalidShelfID,
1785 launcher_controller_->GetShelfIDForAppID(arc_app_id3)); 1784 launcher_controller_->GetShelfIDForAppID(arc_app_id3));
1786 1785
1787 arc::LaunchApp(profile(), arc_app_id1, ui::EF_LEFT_MOUSE_BUTTON); 1786 arc::LaunchApp(profile(), arc_app_id1);
1788 arc::LaunchApp(profile(), arc_app_id1, ui::EF_LEFT_MOUSE_BUTTON); 1787 arc::LaunchApp(profile(), arc_app_id1);
1789 arc::LaunchApp(profile(), arc_app_id2, ui::EF_LEFT_MOUSE_BUTTON); 1788 arc::LaunchApp(profile(), arc_app_id2);
1790 arc::LaunchApp(profile(), arc_app_id3, ui::EF_LEFT_MOUSE_BUTTON); 1789 arc::LaunchApp(profile(), arc_app_id3);
1791 arc::LaunchApp(profile(), arc_app_id3, ui::EF_LEFT_MOUSE_BUTTON); 1790 arc::LaunchApp(profile(), arc_app_id3);
1792 1791
1793 const ash::ShelfID shelf_id_app_1 = 1792 const ash::ShelfID shelf_id_app_1 =
1794 launcher_controller_->GetShelfIDForAppID(arc_app_id1); 1793 launcher_controller_->GetShelfIDForAppID(arc_app_id1);
1795 const ash::ShelfID shelf_id_app_2 = 1794 const ash::ShelfID shelf_id_app_2 =
1796 launcher_controller_->GetShelfIDForAppID(arc_app_id2); 1795 launcher_controller_->GetShelfIDForAppID(arc_app_id2);
1797 const ash::ShelfID shelf_id_app_3 = 1796 const ash::ShelfID shelf_id_app_3 =
1798 launcher_controller_->GetShelfIDForAppID(arc_app_id3); 1797 launcher_controller_->GetShelfIDForAppID(arc_app_id3);
1799 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_1); 1798 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_1);
1800 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_2); 1799 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_2);
1801 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_3); 1800 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_3);
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1939 arc_test_.app_instance()->SendTaskCreated(3, arc_test_.fake_apps()[0]); 1938 arc_test_.app_instance()->SendTaskCreated(3, arc_test_.fake_apps()[0]);
1940 EXPECT_NE(ash::kInvalidShelfID, 1939 EXPECT_NE(ash::kInvalidShelfID,
1941 launcher_controller_->GetShelfIDForAppID(arc_app_id)); 1940 launcher_controller_->GetShelfIDForAppID(arc_app_id));
1942 arc_test_.StopArcInstance(); 1941 arc_test_.StopArcInstance();
1943 base::RunLoop().RunUntilIdle(); 1942 base::RunLoop().RunUntilIdle();
1944 EXPECT_EQ(ash::kInvalidShelfID, 1943 EXPECT_EQ(ash::kInvalidShelfID,
1945 launcher_controller_->GetShelfIDForAppID(arc_app_id)); 1944 launcher_controller_->GetShelfIDForAppID(arc_app_id));
1946 } 1945 }
1947 1946
1948 // Test race creation/deletion of Arc app. 1947 // Test race creation/deletion of Arc app.
1949 // TODO(khmel): Remove after moving everything to wayland protocol. 1948 // TODO (khmel): Remove after moving everything to wayland protocol.
1950 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcRaceCreateClose) { 1949 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcRaceCreateClose) {
1951 InitLauncherController(); 1950 InitLauncherController();
1952 1951
1953 const std::string arc_app_id1 = 1952 const std::string arc_app_id1 =
1954 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); 1953 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
1955 const std::string arc_app_id2 = 1954 const std::string arc_app_id2 =
1956 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); 1955 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]);
1957 SendListOfArcApps(); 1956 SendListOfArcApps();
1958 1957
1959 // Arc window created before and closed after mojom notification. 1958 // Arc window created before and closed after mojom notification.
(...skipping 1999 matching lines...) Expand 10 before | Expand all | Expand 10 after
3959 3958
3960 ArcAppListPrefs* const prefs = arc_test_.arc_app_list_prefs(); 3959 ArcAppListPrefs* const prefs = arc_test_.arc_app_list_prefs();
3961 EnableArc(false); 3960 EnableArc(false);
3962 EXPECT_FALSE(arc_test_.arc_session_manager()->IsArcEnabled()); 3961 EXPECT_FALSE(arc_test_.arc_session_manager()->IsArcEnabled());
3963 ASSERT_TRUE(prefs->GetAppIds().size()); 3962 ASSERT_TRUE(prefs->GetAppIds().size());
3964 3963
3965 const std::string app_id = 3964 const std::string app_id =
3966 ArcAppTest::GetAppId(arc_test_.fake_default_apps()[0]); 3965 ArcAppTest::GetAppId(arc_test_.fake_default_apps()[0]);
3967 EXPECT_EQ(ash::kInvalidShelfID, 3966 EXPECT_EQ(ash::kInvalidShelfID,
3968 launcher_controller_->GetShelfIDForAppID(app_id)); 3967 launcher_controller_->GetShelfIDForAppID(app_id));
3969 EXPECT_TRUE(arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON)); 3968 EXPECT_TRUE(arc::LaunchApp(profile(), app_id));
3970 EXPECT_TRUE(arc_test_.arc_session_manager()->IsArcEnabled()); 3969 EXPECT_TRUE(arc_test_.arc_session_manager()->IsArcEnabled());
3971 EXPECT_NE(ash::kInvalidShelfID, 3970 EXPECT_NE(ash::kInvalidShelfID,
3972 launcher_controller_->GetShelfIDForAppID(app_id)); 3971 launcher_controller_->GetShelfIDForAppID(app_id));
3973 3972
3974 // Stop Arc again. Shelf item should go away. 3973 // Stop Arc again. Shelf item should go away.
3975 EnableArc(false); 3974 EnableArc(false);
3976 EXPECT_EQ(ash::kInvalidShelfID, 3975 EXPECT_EQ(ash::kInvalidShelfID,
3977 launcher_controller_->GetShelfIDForAppID(app_id)); 3976 launcher_controller_->GetShelfIDForAppID(app_id));
3978 3977
3979 EXPECT_TRUE(arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON)); 3978 EXPECT_TRUE(arc::LaunchApp(profile(), app_id));
3980 EXPECT_TRUE(arc_test_.arc_session_manager()->IsArcEnabled()); 3979 EXPECT_TRUE(arc_test_.arc_session_manager()->IsArcEnabled());
3981 3980
3982 EXPECT_NE(ash::kInvalidShelfID, 3981 EXPECT_NE(ash::kInvalidShelfID,
3983 launcher_controller_->GetShelfIDForAppID(app_id)); 3982 launcher_controller_->GetShelfIDForAppID(app_id));
3984 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); 3983 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id));
3985 3984
3986 std::string window_app_id("org.chromium.arc.1"); 3985 std::string window_app_id("org.chromium.arc.1");
3987 CreateArcWindow(window_app_id); 3986 CreateArcWindow(window_app_id);
3988 arc_test_.app_instance()->SendTaskCreated(1, 3987 arc_test_.app_instance()->SendTaskCreated(1,
3989 arc_test_.fake_default_apps()[0]); 3988 arc_test_.fake_default_apps()[0]);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
4067 4066
4068 // Pinned state should not change. 4067 // Pinned state should not change.
4069 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); 4068 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus());
4070 launcher_controller_->UnpinAppWithID(extension2_->id()); 4069 launcher_controller_->UnpinAppWithID(extension2_->id());
4071 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus()); 4070 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus());
4072 4071
4073 // Resume syncing and sync information overrides local copy. 4072 // Resume syncing and sync information overrides local copy.
4074 StartAppSyncService(copy_sync_list); 4073 StartAppSyncService(copy_sync_list);
4075 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); 4074 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus());
4076 } 4075 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698