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

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

Issue 2553673003: [Merge to M55] 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 #include "extensions/browser/app_window/native_app_window.h" 95 #include "extensions/browser/app_window/native_app_window.h"
96 #include "extensions/common/extension.h" 96 #include "extensions/common/extension.h"
97 #include "extensions/common/manifest_constants.h" 97 #include "extensions/common/manifest_constants.h"
98 #include "testing/gtest/include/gtest/gtest.h" 98 #include "testing/gtest/include/gtest/gtest.h"
99 #include "ui/aura/client/window_tree_client.h" 99 #include "ui/aura/client/window_tree_client.h"
100 #include "ui/aura/window.h" 100 #include "ui/aura/window.h"
101 #include "ui/base/models/menu_model.h" 101 #include "ui/base/models/menu_model.h"
102 #include "ui/display/display.h" 102 #include "ui/display/display.h"
103 #include "ui/display/display_switches.h" 103 #include "ui/display/display_switches.h"
104 #include "ui/display/screen.h" 104 #include "ui/display/screen.h"
105 #include "ui/events/event_constants.h"
105 #include "ui/views/widget/widget.h" 106 #include "ui/views/widget/widget.h"
106 107
107 using base::ASCIIToUTF16; 108 using base::ASCIIToUTF16;
108 using extensions::Extension; 109 using extensions::Extension;
109 using extensions::Manifest; 110 using extensions::Manifest;
110 using extensions::UnloadedExtensionInfo; 111 using extensions::UnloadedExtensionInfo;
111 using arc::mojom::OrientationLock; 112 using arc::mojom::OrientationLock;
112 113
113 namespace { 114 namespace {
114 const char* offline_gmail_url = "https://mail.google.com/mail/mu/u"; 115 const char* offline_gmail_url = "https://mail.google.com/mail/mu/u";
(...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1218 1219
1219 ash::test::TestShellDelegate* shell_delegate_; 1220 ash::test::TestShellDelegate* shell_delegate_;
1220 1221
1221 ProfileToNameMap created_profiles_; 1222 ProfileToNameMap created_profiles_;
1222 1223
1223 DISALLOW_COPY_AND_ASSIGN( 1224 DISALLOW_COPY_AND_ASSIGN(
1224 MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest); 1225 MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest);
1225 }; 1226 };
1226 1227
1227 class ChromeLauncherControllerImplMultiProfileWithArcTest 1228 class ChromeLauncherControllerImplMultiProfileWithArcTest
1228 : public MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest { 1229 : public MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest { // NOLINT(whitespace/line_length)
1229 protected: 1230 protected:
1230 ChromeLauncherControllerImplMultiProfileWithArcTest() { 1231 ChromeLauncherControllerImplMultiProfileWithArcTest() {
1231 auto_start_arc_test_ = true; 1232 auto_start_arc_test_ = true;
1232 } 1233 }
1233 ~ChromeLauncherControllerImplMultiProfileWithArcTest() override {} 1234 ~ChromeLauncherControllerImplMultiProfileWithArcTest() override {}
1234 1235
1235 private: 1236 private:
1236 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImplMultiProfileWithArcTest); 1237 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImplMultiProfileWithArcTest);
1237 }; 1238 };
1238 1239
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
1790 const std::string arc_app_id3 = ArcAppTest::GetAppId(app3); 1791 const std::string arc_app_id3 = ArcAppTest::GetAppId(app3);
1791 1792
1792 SendListOfArcApps(); 1793 SendListOfArcApps();
1793 1794
1794 arc_test_.StopArcInstance(); 1795 arc_test_.StopArcInstance();
1795 1796
1796 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id1)); 1797 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id1));
1797 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2)); 1798 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2));
1798 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id3)); 1799 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id3));
1799 1800
1800 arc::LaunchApp(profile(), arc_app_id1); 1801 arc::LaunchApp(profile(), arc_app_id1, ui::EF_LEFT_MOUSE_BUTTON);
1801 arc::LaunchApp(profile(), arc_app_id1); 1802 arc::LaunchApp(profile(), arc_app_id1, ui::EF_LEFT_MOUSE_BUTTON);
1802 arc::LaunchApp(profile(), arc_app_id2); 1803 arc::LaunchApp(profile(), arc_app_id2, ui::EF_LEFT_MOUSE_BUTTON);
1803 arc::LaunchApp(profile(), arc_app_id3); 1804 arc::LaunchApp(profile(), arc_app_id3, ui::EF_LEFT_MOUSE_BUTTON);
1804 arc::LaunchApp(profile(), arc_app_id3); 1805 arc::LaunchApp(profile(), arc_app_id3, ui::EF_LEFT_MOUSE_BUTTON);
1805 1806
1806 const ash::ShelfID shelf_id_app_1 = 1807 const ash::ShelfID shelf_id_app_1 =
1807 launcher_controller_->GetShelfIDForAppID(arc_app_id1); 1808 launcher_controller_->GetShelfIDForAppID(arc_app_id1);
1808 const ash::ShelfID shelf_id_app_2 = 1809 const ash::ShelfID shelf_id_app_2 =
1809 launcher_controller_->GetShelfIDForAppID(arc_app_id2); 1810 launcher_controller_->GetShelfIDForAppID(arc_app_id2);
1810 const ash::ShelfID shelf_id_app_3 = 1811 const ash::ShelfID shelf_id_app_3 =
1811 launcher_controller_->GetShelfIDForAppID(arc_app_id3); 1812 launcher_controller_->GetShelfIDForAppID(arc_app_id3);
1812 EXPECT_NE(0, shelf_id_app_1); 1813 EXPECT_NE(0, shelf_id_app_1);
1813 EXPECT_NE(0, shelf_id_app_2); 1814 EXPECT_NE(0, shelf_id_app_2);
1814 EXPECT_NE(0, shelf_id_app_3); 1815 EXPECT_NE(0, shelf_id_app_3);
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1933 // Stopping bridge removes apps. 1934 // Stopping bridge removes apps.
1934 CreateArcWindow(window_app_id3); 1935 CreateArcWindow(window_app_id3);
1935 arc_test_.app_instance()->SendTaskCreated(3, arc_test_.fake_apps()[0]); 1936 arc_test_.app_instance()->SendTaskCreated(3, arc_test_.fake_apps()[0]);
1936 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); 1937 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id));
1937 arc_test_.StopArcInstance(); 1938 arc_test_.StopArcInstance();
1938 base::RunLoop().RunUntilIdle(); 1939 base::RunLoop().RunUntilIdle();
1939 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); 1940 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id));
1940 } 1941 }
1941 1942
1942 // Test race creation/deletion of Arc app. 1943 // Test race creation/deletion of Arc app.
1943 // TODO (khmel): Remove after moving everything to wayland protocol. 1944 // TODO(khmel): Remove after moving everything to wayland protocol.
1944 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcRaceCreateClose) { 1945 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcRaceCreateClose) {
1945 InitLauncherController(); 1946 InitLauncherController();
1946 1947
1947 const std::string arc_app_id1 = 1948 const std::string arc_app_id1 =
1948 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); 1949 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
1949 const std::string arc_app_id2 = 1950 const std::string arc_app_id2 =
1950 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); 1951 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]);
1951 SendListOfArcApps(); 1952 SendListOfArcApps();
1952 1953
1953 // Arc window created before and closed after mojom notification. 1954 // Arc window created before and closed after mojom notification.
(...skipping 1983 matching lines...) Expand 10 before | Expand all | Expand 10 after
3937 arc::ArcAuthService::SetShelfDelegateForTesting(launcher_controller_.get()); 3938 arc::ArcAuthService::SetShelfDelegateForTesting(launcher_controller_.get());
3938 3939
3939 ArcAppListPrefs* const prefs = arc_test_.arc_app_list_prefs(); 3940 ArcAppListPrefs* const prefs = arc_test_.arc_app_list_prefs();
3940 EnableArc(false); 3941 EnableArc(false);
3941 EXPECT_FALSE(arc_test_.arc_auth_service()->IsArcEnabled()); 3942 EXPECT_FALSE(arc_test_.arc_auth_service()->IsArcEnabled());
3942 ASSERT_TRUE(prefs->GetAppIds().size()); 3943 ASSERT_TRUE(prefs->GetAppIds().size());
3943 3944
3944 const std::string app_id = 3945 const std::string app_id =
3945 ArcAppTest::GetAppId(arc_test_.fake_default_apps()[0]); 3946 ArcAppTest::GetAppId(arc_test_.fake_default_apps()[0]);
3946 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(app_id)); 3947 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(app_id));
3947 EXPECT_TRUE(arc::LaunchApp(profile(), app_id)); 3948 EXPECT_TRUE(arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON));
3948 EXPECT_TRUE(arc_test_.arc_auth_service()->IsArcEnabled()); 3949 EXPECT_TRUE(arc_test_.arc_auth_service()->IsArcEnabled());
3949 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(app_id)); 3950 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(app_id));
3950 3951
3951 // Stop Arc again. Shelf item should go away. 3952 // Stop Arc again. Shelf item should go away.
3952 EnableArc(false); 3953 EnableArc(false);
3953 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(app_id)); 3954 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(app_id));
3954 3955
3955 EXPECT_TRUE(arc::LaunchApp(profile(), app_id)); 3956 EXPECT_TRUE(arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON));
3956 EXPECT_TRUE(arc_test_.arc_auth_service()->IsArcEnabled()); 3957 EXPECT_TRUE(arc_test_.arc_auth_service()->IsArcEnabled());
3957 3958
3958 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(app_id)); 3959 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(app_id));
3959 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); 3960 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id));
3960 3961
3961 std::string window_app_id("org.chromium.arc.1"); 3962 std::string window_app_id("org.chromium.arc.1");
3962 CreateArcWindow(window_app_id); 3963 CreateArcWindow(window_app_id);
3963 arc_test_.app_instance()->SendTaskCreated(1, 3964 arc_test_.app_instance()->SendTaskCreated(1,
3964 arc_test_.fake_default_apps()[0]); 3965 arc_test_.fake_default_apps()[0]);
3965 3966
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
4009 app_service_->GetPinPosition(extension_misc::kChromeAppId))); 4010 app_service_->GetPinPosition(extension_misc::kChromeAppId)));
4010 EXPECT_TRUE( 4011 EXPECT_TRUE(
4011 position_1.Equals(app_service_->GetPinPosition(extension1_->id()))); 4012 position_1.Equals(app_service_->GetPinPosition(extension1_->id())));
4012 EXPECT_TRUE( 4013 EXPECT_TRUE(
4013 position_1.Equals(app_service_->GetPinPosition(extension1_->id()))); 4014 position_1.Equals(app_service_->GetPinPosition(extension1_->id())));
4014 EXPECT_TRUE( 4015 EXPECT_TRUE(
4015 position_2.Equals(app_service_->GetPinPosition(extension2_->id()))); 4016 position_2.Equals(app_service_->GetPinPosition(extension2_->id())));
4016 EXPECT_TRUE( 4017 EXPECT_TRUE(
4017 position_3.Equals(app_service_->GetPinPosition(extension3_->id()))); 4018 position_3.Equals(app_service_->GetPinPosition(extension3_->id())));
4018 } 4019 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698