| OLD | NEW |
| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 #include "chrome/common/extensions/extension_constants.h" | 72 #include "chrome/common/extensions/extension_constants.h" |
| 73 #include "chrome/common/pref_names.h" | 73 #include "chrome/common/pref_names.h" |
| 74 #include "chrome/test/base/browser_with_test_window_test.h" | 74 #include "chrome/test/base/browser_with_test_window_test.h" |
| 75 #include "chrome/test/base/test_browser_window_aura.h" | 75 #include "chrome/test/base/test_browser_window_aura.h" |
| 76 #include "chrome/test/base/testing_browser_process.h" | 76 #include "chrome/test/base/testing_browser_process.h" |
| 77 #include "chrome/test/base/testing_profile.h" | 77 #include "chrome/test/base/testing_profile.h" |
| 78 #include "chrome/test/base/testing_profile_manager.h" | 78 #include "chrome/test/base/testing_profile_manager.h" |
| 79 #include "chromeos/chromeos_switches.h" | 79 #include "chromeos/chromeos_switches.h" |
| 80 #include "components/arc/common/app.mojom.h" | 80 #include "components/arc/common/app.mojom.h" |
| 81 #include "components/arc/test/fake_app_instance.h" | 81 #include "components/arc/test/fake_app_instance.h" |
| 82 #include "components/arc/test/fake_arc_bridge_service.h" | |
| 83 #include "components/exo/shell_surface.h" | 82 #include "components/exo/shell_surface.h" |
| 84 #include "components/signin/core/account_id/account_id.h" | 83 #include "components/signin/core/account_id/account_id.h" |
| 85 #include "components/syncable_prefs/testing_pref_service_syncable.h" | 84 #include "components/syncable_prefs/testing_pref_service_syncable.h" |
| 86 #include "components/user_manager/fake_user_manager.h" | 85 #include "components/user_manager/fake_user_manager.h" |
| 87 #include "content/public/browser/web_contents.h" | 86 #include "content/public/browser/web_contents.h" |
| 88 #include "content/public/browser/web_contents_observer.h" | 87 #include "content/public/browser/web_contents_observer.h" |
| 89 #include "content/public/test/test_utils.h" | 88 #include "content/public/test/test_utils.h" |
| 90 #include "content/public/test/web_contents_tester.h" | 89 #include "content/public/test/web_contents_tester.h" |
| 91 #include "extensions/browser/app_window/app_window_contents.h" | 90 #include "extensions/browser/app_window/app_window_contents.h" |
| 92 #include "extensions/browser/app_window/app_window_registry.h" | 91 #include "extensions/browser/app_window/app_window_registry.h" |
| (...skipping 1681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1774 | 1773 |
| 1775 const arc::mojom::AppInfo& app1 = arc_test_.fake_apps()[0]; | 1774 const arc::mojom::AppInfo& app1 = arc_test_.fake_apps()[0]; |
| 1776 const arc::mojom::AppInfo& app2 = arc_test_.fake_apps()[1]; | 1775 const arc::mojom::AppInfo& app2 = arc_test_.fake_apps()[1]; |
| 1777 const arc::mojom::AppInfo& app3 = arc_test_.fake_apps()[2]; | 1776 const arc::mojom::AppInfo& app3 = arc_test_.fake_apps()[2]; |
| 1778 const std::string arc_app_id1 = ArcAppTest::GetAppId(app1); | 1777 const std::string arc_app_id1 = ArcAppTest::GetAppId(app1); |
| 1779 const std::string arc_app_id2 = ArcAppTest::GetAppId(app2); | 1778 const std::string arc_app_id2 = ArcAppTest::GetAppId(app2); |
| 1780 const std::string arc_app_id3 = ArcAppTest::GetAppId(app3); | 1779 const std::string arc_app_id3 = ArcAppTest::GetAppId(app3); |
| 1781 | 1780 |
| 1782 SendListOfArcApps(); | 1781 SendListOfArcApps(); |
| 1783 | 1782 |
| 1784 arc_test_.bridge_service()->SetStopped(); | 1783 arc_test_.StopArcInstance(); |
| 1785 | 1784 |
| 1786 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id1)); | 1785 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id1)); |
| 1787 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2)); | 1786 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2)); |
| 1788 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id3)); | 1787 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id3)); |
| 1789 | 1788 |
| 1790 arc::LaunchApp(profile(), arc_app_id1); | 1789 arc::LaunchApp(profile(), arc_app_id1); |
| 1791 arc::LaunchApp(profile(), arc_app_id1); | 1790 arc::LaunchApp(profile(), arc_app_id1); |
| 1792 arc::LaunchApp(profile(), arc_app_id2); | 1791 arc::LaunchApp(profile(), arc_app_id2); |
| 1793 arc::LaunchApp(profile(), arc_app_id3); | 1792 arc::LaunchApp(profile(), arc_app_id3); |
| 1794 arc::LaunchApp(profile(), arc_app_id3); | 1793 arc::LaunchApp(profile(), arc_app_id3); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1810 ASSERT_NE(nullptr, item_controller); | 1809 ASSERT_NE(nullptr, item_controller); |
| 1811 item_controller->Close(); | 1810 item_controller->Close(); |
| 1812 base::RunLoop().RunUntilIdle(); | 1811 base::RunLoop().RunUntilIdle(); |
| 1813 | 1812 |
| 1814 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id1)); | 1813 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id1)); |
| 1815 EXPECT_EQ(shelf_id_app_2, | 1814 EXPECT_EQ(shelf_id_app_2, |
| 1816 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); | 1815 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); |
| 1817 EXPECT_EQ(shelf_id_app_3, | 1816 EXPECT_EQ(shelf_id_app_3, |
| 1818 launcher_controller_->GetShelfIDForAppID(arc_app_id3)); | 1817 launcher_controller_->GetShelfIDForAppID(arc_app_id3)); |
| 1819 | 1818 |
| 1820 arc_test_.bridge_service()->SetReady(); | 1819 arc_test_.RestartArcInstance(); |
| 1821 SendListOfArcApps(); | 1820 SendListOfArcApps(); |
| 1822 | 1821 |
| 1823 base::RunLoop().RunUntilIdle(); | 1822 base::RunLoop().RunUntilIdle(); |
| 1824 | 1823 |
| 1825 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id1)); | 1824 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id1)); |
| 1826 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2)); | 1825 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2)); |
| 1827 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id3)); | 1826 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id3)); |
| 1828 | 1827 |
| 1829 ASSERT_EQ(2U, arc_test_.app_instance()->launch_requests().size()); | 1828 ASSERT_EQ(2U, arc_test_.app_instance()->launch_requests().size()); |
| 1830 | 1829 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1851 arc_test_.app_instance()->SendTaskCreated(2, arc_test_.fake_apps()[0]); | 1850 arc_test_.app_instance()->SendTaskCreated(2, arc_test_.fake_apps()[0]); |
| 1852 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); | 1851 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); |
| 1853 arc_test_.app_instance()->SendTaskDestroyed(1); | 1852 arc_test_.app_instance()->SendTaskDestroyed(1); |
| 1854 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); | 1853 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); |
| 1855 arc_test_.app_instance()->SendTaskDestroyed(2); | 1854 arc_test_.app_instance()->SendTaskDestroyed(2); |
| 1856 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); | 1855 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); |
| 1857 | 1856 |
| 1858 // Stopping bridge removes apps. | 1857 // Stopping bridge removes apps. |
| 1859 arc_test_.app_instance()->SendTaskCreated(3, arc_test_.fake_apps()[0]); | 1858 arc_test_.app_instance()->SendTaskCreated(3, arc_test_.fake_apps()[0]); |
| 1860 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); | 1859 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); |
| 1861 arc_test_.bridge_service()->SetStopped(); | 1860 arc_test_.StopArcInstance(); |
| 1862 base::RunLoop().RunUntilIdle(); | 1861 base::RunLoop().RunUntilIdle(); |
| 1863 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); | 1862 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); |
| 1864 } | 1863 } |
| 1865 | 1864 |
| 1866 // Validate that Arc app is pinned correctly and pin is removed automatically | 1865 // Validate that Arc app is pinned correctly and pin is removed automatically |
| 1867 // once app is uninstalled. | 1866 // once app is uninstalled. |
| 1868 TEST_F(ChromeLauncherControllerImplTest, ArcAppPin) { | 1867 TEST_F(ChromeLauncherControllerImplTest, ArcAppPin) { |
| 1869 arc_test_.SetUp(profile()); | 1868 arc_test_.SetUp(profile()); |
| 1870 InitLauncherController(); | 1869 InitLauncherController(); |
| 1871 | 1870 |
| (...skipping 1825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3697 EXPECT_FALSE(controller->rotation_locked()); | 3696 EXPECT_FALSE(controller->rotation_locked()); |
| 3698 EXPECT_EQ(display::Display::ROTATE_0, | 3697 EXPECT_EQ(display::Display::ROTATE_0, |
| 3699 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); | 3698 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); |
| 3700 | 3699 |
| 3701 NotifyOnTaskOrientationLockRequested(task_id_current_, | 3700 NotifyOnTaskOrientationLockRequested(task_id_current_, |
| 3702 OrientationLock::CURRENT); | 3701 OrientationLock::CURRENT); |
| 3703 EXPECT_TRUE(controller->rotation_locked()); | 3702 EXPECT_TRUE(controller->rotation_locked()); |
| 3704 EXPECT_EQ(display::Display::ROTATE_0, | 3703 EXPECT_EQ(display::Display::ROTATE_0, |
| 3705 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); | 3704 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); |
| 3706 } | 3705 } |
| OLD | NEW |