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

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

Issue 2550683002: [Merge to 2924] Reland "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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 #include "extensions/browser/app_window/native_app_window.h" 96 #include "extensions/browser/app_window/native_app_window.h"
97 #include "extensions/common/extension.h" 97 #include "extensions/common/extension.h"
98 #include "extensions/common/manifest_constants.h" 98 #include "extensions/common/manifest_constants.h"
99 #include "testing/gtest/include/gtest/gtest.h" 99 #include "testing/gtest/include/gtest/gtest.h"
100 #include "ui/aura/client/window_parenting_client.h" 100 #include "ui/aura/client/window_parenting_client.h"
101 #include "ui/aura/window.h" 101 #include "ui/aura/window.h"
102 #include "ui/base/models/menu_model.h" 102 #include "ui/base/models/menu_model.h"
103 #include "ui/display/display.h" 103 #include "ui/display/display.h"
104 #include "ui/display/display_switches.h" 104 #include "ui/display/display_switches.h"
105 #include "ui/display/screen.h" 105 #include "ui/display/screen.h"
106 #include "ui/events/event_constants.h"
106 #include "ui/views/widget/widget.h" 107 #include "ui/views/widget/widget.h"
107 108
108 using base::ASCIIToUTF16; 109 using base::ASCIIToUTF16;
109 using extensions::Extension; 110 using extensions::Extension;
110 using extensions::Manifest; 111 using extensions::Manifest;
111 using extensions::UnloadedExtensionInfo; 112 using extensions::UnloadedExtensionInfo;
112 using arc::mojom::OrientationLock; 113 using arc::mojom::OrientationLock;
113 114
114 namespace { 115 namespace {
115 const char* offline_gmail_url = "https://mail.google.com/mail/mu/u"; 116 const char* offline_gmail_url = "https://mail.google.com/mail/mu/u";
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 bool arc_managed, 827 bool arc_managed,
827 arc::ArcAuthService::State state, 828 arc::ArcAuthService::State state,
828 const std::string& pin_status) { 829 const std::string& pin_status) {
829 EXPECT_EQ(arc_managed, arc_test_.arc_auth_service()->IsArcManaged()); 830 EXPECT_EQ(arc_managed, arc_test_.arc_auth_service()->IsArcManaged());
830 EXPECT_EQ(arc_enabled, arc_test_.arc_auth_service()->IsArcEnabled()); 831 EXPECT_EQ(arc_enabled, arc_test_.arc_auth_service()->IsArcEnabled());
831 EXPECT_EQ(state, arc_test_.arc_auth_service()->state()); 832 EXPECT_EQ(state, arc_test_.arc_auth_service()->state());
832 EXPECT_EQ(pin_status, GetPinnedAppStatus()); 833 EXPECT_EQ(pin_status, GetPinnedAppStatus());
833 } 834 }
834 835
835 // Creates app window and set optional Arc application id. 836 // Creates app window and set optional Arc application id.
836 views::Widget* CreateArcWindow(std::string& window_app_id) { 837 views::Widget* CreateArcWindow(const std::string& window_app_id) {
837 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 838 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
838 params.bounds = gfx::Rect(5, 5, 20, 20); 839 params.bounds = gfx::Rect(5, 5, 20, 20);
839 params.context = GetContext(); 840 params.context = GetContext();
840 views::Widget* widget = new views::Widget(); 841 views::Widget* widget = new views::Widget();
841 widget->Init(params); 842 widget->Init(params);
842 // Set Arc id before showing the window to be recognized in 843 // Set Arc id before showing the window to be recognized in
843 // ArcAppWindowLauncherController. 844 // ArcAppWindowLauncherController.
844 exo::ShellSurface::SetApplicationId(widget->GetNativeWindow(), 845 exo::ShellSurface::SetApplicationId(widget->GetNativeWindow(),
845 window_app_id); 846 window_app_id);
846 widget->Show(); 847 widget->Show();
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
1209 1210
1210 ash::test::TestShellDelegate* shell_delegate_; 1211 ash::test::TestShellDelegate* shell_delegate_;
1211 1212
1212 ProfileToNameMap created_profiles_; 1213 ProfileToNameMap created_profiles_;
1213 1214
1214 DISALLOW_COPY_AND_ASSIGN( 1215 DISALLOW_COPY_AND_ASSIGN(
1215 MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest); 1216 MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest);
1216 }; 1217 };
1217 1218
1218 class ChromeLauncherControllerImplMultiProfileWithArcTest 1219 class ChromeLauncherControllerImplMultiProfileWithArcTest
1219 : public MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest { 1220 : public MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest { // NOLINT(whitespace/line_length)
1220 protected: 1221 protected:
1221 ChromeLauncherControllerImplMultiProfileWithArcTest() { 1222 ChromeLauncherControllerImplMultiProfileWithArcTest() {
1222 auto_start_arc_test_ = true; 1223 auto_start_arc_test_ = true;
1223 } 1224 }
1224 ~ChromeLauncherControllerImplMultiProfileWithArcTest() override {} 1225 ~ChromeLauncherControllerImplMultiProfileWithArcTest() override {}
1225 1226
1226 private: 1227 private:
1227 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImplMultiProfileWithArcTest); 1228 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImplMultiProfileWithArcTest);
1228 }; 1229 };
1229 1230
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
1781 const std::string arc_app_id3 = ArcAppTest::GetAppId(app3); 1782 const std::string arc_app_id3 = ArcAppTest::GetAppId(app3);
1782 1783
1783 SendListOfArcApps(); 1784 SendListOfArcApps();
1784 1785
1785 arc_test_.StopArcInstance(); 1786 arc_test_.StopArcInstance();
1786 1787
1787 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id1)); 1788 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id1));
1788 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2)); 1789 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2));
1789 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id3)); 1790 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id3));
1790 1791
1791 arc::LaunchApp(profile(), arc_app_id1); 1792 arc::LaunchApp(profile(), arc_app_id1, ui::EF_LEFT_MOUSE_BUTTON);
1792 arc::LaunchApp(profile(), arc_app_id1); 1793 arc::LaunchApp(profile(), arc_app_id1, ui::EF_LEFT_MOUSE_BUTTON);
1793 arc::LaunchApp(profile(), arc_app_id2); 1794 arc::LaunchApp(profile(), arc_app_id2, ui::EF_LEFT_MOUSE_BUTTON);
1794 arc::LaunchApp(profile(), arc_app_id3); 1795 arc::LaunchApp(profile(), arc_app_id3, ui::EF_LEFT_MOUSE_BUTTON);
1795 arc::LaunchApp(profile(), arc_app_id3); 1796 arc::LaunchApp(profile(), arc_app_id3, ui::EF_LEFT_MOUSE_BUTTON);
1796 1797
1797 const ash::ShelfID shelf_id_app_1 = 1798 const ash::ShelfID shelf_id_app_1 =
1798 launcher_controller_->GetShelfIDForAppID(arc_app_id1); 1799 launcher_controller_->GetShelfIDForAppID(arc_app_id1);
1799 const ash::ShelfID shelf_id_app_2 = 1800 const ash::ShelfID shelf_id_app_2 =
1800 launcher_controller_->GetShelfIDForAppID(arc_app_id2); 1801 launcher_controller_->GetShelfIDForAppID(arc_app_id2);
1801 const ash::ShelfID shelf_id_app_3 = 1802 const ash::ShelfID shelf_id_app_3 =
1802 launcher_controller_->GetShelfIDForAppID(arc_app_id3); 1803 launcher_controller_->GetShelfIDForAppID(arc_app_id3);
1803 EXPECT_NE(0, shelf_id_app_1); 1804 EXPECT_NE(0, shelf_id_app_1);
1804 EXPECT_NE(0, shelf_id_app_2); 1805 EXPECT_NE(0, shelf_id_app_2);
1805 EXPECT_NE(0, shelf_id_app_3); 1806 EXPECT_NE(0, shelf_id_app_3);
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1924 // Stopping bridge removes apps. 1925 // Stopping bridge removes apps.
1925 CreateArcWindow(window_app_id3); 1926 CreateArcWindow(window_app_id3);
1926 arc_test_.app_instance()->SendTaskCreated(3, arc_test_.fake_apps()[0]); 1927 arc_test_.app_instance()->SendTaskCreated(3, arc_test_.fake_apps()[0]);
1927 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); 1928 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id));
1928 arc_test_.StopArcInstance(); 1929 arc_test_.StopArcInstance();
1929 base::RunLoop().RunUntilIdle(); 1930 base::RunLoop().RunUntilIdle();
1930 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); 1931 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id));
1931 } 1932 }
1932 1933
1933 // Test race creation/deletion of Arc app. 1934 // Test race creation/deletion of Arc app.
1934 // TODO (khmel): Remove after moving everything to wayland protocol. 1935 // TODO(khmel): Remove after moving everything to wayland protocol.
1935 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcRaceCreateClose) { 1936 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcRaceCreateClose) {
1936 InitLauncherController(); 1937 InitLauncherController();
1937 1938
1938 const std::string arc_app_id1 = 1939 const std::string arc_app_id1 =
1939 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); 1940 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
1940 const std::string arc_app_id2 = 1941 const std::string arc_app_id2 =
1941 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); 1942 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]);
1942 SendListOfArcApps(); 1943 SendListOfArcApps();
1943 1944
1944 // Arc window created before and closed after mojom notification. 1945 // Arc window created before and closed after mojom notification.
(...skipping 1976 matching lines...) Expand 10 before | Expand all | Expand 10 after
3921 arc::ArcAuthService::SetShelfDelegateForTesting(launcher_controller_.get()); 3922 arc::ArcAuthService::SetShelfDelegateForTesting(launcher_controller_.get());
3922 3923
3923 ArcAppListPrefs* const prefs = arc_test_.arc_app_list_prefs(); 3924 ArcAppListPrefs* const prefs = arc_test_.arc_app_list_prefs();
3924 EnableArc(false); 3925 EnableArc(false);
3925 EXPECT_FALSE(arc_test_.arc_auth_service()->IsArcEnabled()); 3926 EXPECT_FALSE(arc_test_.arc_auth_service()->IsArcEnabled());
3926 ASSERT_TRUE(prefs->GetAppIds().size()); 3927 ASSERT_TRUE(prefs->GetAppIds().size());
3927 3928
3928 const std::string app_id = 3929 const std::string app_id =
3929 ArcAppTest::GetAppId(arc_test_.fake_default_apps()[0]); 3930 ArcAppTest::GetAppId(arc_test_.fake_default_apps()[0]);
3930 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(app_id)); 3931 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(app_id));
3931 EXPECT_TRUE(arc::LaunchApp(profile(), app_id)); 3932 EXPECT_TRUE(arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON));
3932 EXPECT_TRUE(arc_test_.arc_auth_service()->IsArcEnabled()); 3933 EXPECT_TRUE(arc_test_.arc_auth_service()->IsArcEnabled());
3933 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(app_id)); 3934 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(app_id));
3934 3935
3935 // Stop Arc again. Shelf item should go away. 3936 // Stop Arc again. Shelf item should go away.
3936 EnableArc(false); 3937 EnableArc(false);
3937 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(app_id)); 3938 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(app_id));
3938 3939
3939 EXPECT_TRUE(arc::LaunchApp(profile(), app_id)); 3940 EXPECT_TRUE(arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON));
3940 EXPECT_TRUE(arc_test_.arc_auth_service()->IsArcEnabled()); 3941 EXPECT_TRUE(arc_test_.arc_auth_service()->IsArcEnabled());
3941 3942
3942 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(app_id)); 3943 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(app_id));
3943 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); 3944 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id));
3944 3945
3945 std::string window_app_id("org.chromium.arc.1"); 3946 std::string window_app_id("org.chromium.arc.1");
3946 CreateArcWindow(window_app_id); 3947 CreateArcWindow(window_app_id);
3947 arc_test_.app_instance()->SendTaskCreated(1, 3948 arc_test_.app_instance()->SendTaskCreated(1,
3948 arc_test_.fake_default_apps()[0]); 3949 arc_test_.fake_default_apps()[0]);
3949 3950
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
4025 4026
4026 // Pinned state should not change. 4027 // Pinned state should not change.
4027 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); 4028 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus());
4028 launcher_controller_->UnpinAppWithID(extension2_->id()); 4029 launcher_controller_->UnpinAppWithID(extension2_->id());
4029 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus()); 4030 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus());
4030 4031
4031 // Resume syncing and sync information overrides local copy. 4032 // Resume syncing and sync information overrides local copy.
4032 StartAppSyncService(copy_sync_list); 4033 StartAppSyncService(copy_sync_list);
4033 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); 4034 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus());
4034 } 4035 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698