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 1892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1903 | 1903 |
1904 const arc::FakeAppInstance::Request* request1 = | 1904 const arc::FakeAppInstance::Request* request1 = |
1905 arc_test_.app_instance()->launch_requests()[0].get(); | 1905 arc_test_.app_instance()->launch_requests()[0].get(); |
1906 const arc::FakeAppInstance::Request* request2 = | 1906 const arc::FakeAppInstance::Request* request2 = |
1907 arc_test_.app_instance()->launch_requests()[1].get(); | 1907 arc_test_.app_instance()->launch_requests()[1].get(); |
1908 | 1908 |
1909 EXPECT_TRUE((request1->IsForApp(app2) && request2->IsForApp(app3)) || | 1909 EXPECT_TRUE((request1->IsForApp(app2) && request2->IsForApp(app3)) || |
1910 (request1->IsForApp(app3) && request2->IsForApp(app2))); | 1910 (request1->IsForApp(app3) && request2->IsForApp(app2))); |
1911 } | 1911 } |
1912 | 1912 |
| 1913 // Ensure the deferred controller does not override the active app controller |
| 1914 // (crbug.com/701152). |
| 1915 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcDeferredLaunchForActiveApp) { |
| 1916 RecreateChromeLauncher(); |
| 1917 SendListOfArcApps(); |
| 1918 arc_test_.StopArcInstance(); |
| 1919 |
| 1920 const arc::mojom::AppInfo& app = arc_test_.fake_apps()[0]; |
| 1921 const std::string app_id = ArcAppTest::GetAppId(app); |
| 1922 |
| 1923 launcher_controller_->PinAppWithID(app_id); |
| 1924 EXPECT_TRUE(launcher_controller_->IsAppPinned(app_id)); |
| 1925 const ash::ShelfID shelf_id = |
| 1926 launcher_controller_->GetShelfIDForAppID(app_id); |
| 1927 EXPECT_NE(ash::kInvalidShelfID, shelf_id); |
| 1928 |
| 1929 int item_index = model_->ItemIndexByID(shelf_id); |
| 1930 ASSERT_GE(item_index, 0); |
| 1931 |
| 1932 EXPECT_EQ(model_->items()[item_index].status, ash::STATUS_CLOSED); |
| 1933 EXPECT_EQ(model_->items()[item_index].type, ash::TYPE_APP_SHORTCUT); |
| 1934 |
| 1935 // Play Store app is ARC app that might be represented by native Chrome |
| 1936 // platform app. |
| 1937 AppWindowLauncherItemController* app_controller = |
| 1938 new ExtensionAppWindowLauncherItemController(app_id, "", |
| 1939 launcher_controller_.get()); |
| 1940 launcher_controller_->SetItemController(shelf_id, app_controller); |
| 1941 launcher_controller_->SetItemStatus(shelf_id, ash::STATUS_RUNNING); |
| 1942 |
| 1943 // This launch request should be ignored in case of active app. |
| 1944 arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON); |
| 1945 EXPECT_FALSE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); |
| 1946 |
| 1947 // Close app but shortcut should exist. |
| 1948 launcher_controller_->CloseLauncherItem(shelf_id); |
| 1949 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(app_id)); |
| 1950 |
| 1951 // This should switch shelf item into closed state. |
| 1952 item_index = model_->ItemIndexByID(shelf_id); |
| 1953 ASSERT_GE(item_index, 0); |
| 1954 EXPECT_EQ(model_->items()[item_index].status, ash::STATUS_CLOSED); |
| 1955 EXPECT_EQ(model_->items()[item_index].type, ash::TYPE_APP_SHORTCUT); |
| 1956 |
| 1957 // Now launch request should not be ignored. |
| 1958 arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON); |
| 1959 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); |
| 1960 } |
| 1961 |
1913 TEST_F(ChromeLauncherControllerImplMultiProfileWithArcTest, ArcMultiUser) { | 1962 TEST_F(ChromeLauncherControllerImplMultiProfileWithArcTest, ArcMultiUser) { |
1914 SendListOfArcApps(); | 1963 SendListOfArcApps(); |
1915 | 1964 |
1916 InitLauncherController(); | 1965 InitLauncherController(); |
1917 SetLauncherControllerHelper(new TestLauncherControllerHelper); | 1966 SetLauncherControllerHelper(new TestLauncherControllerHelper); |
1918 | 1967 |
1919 // App1 exists all the time. | 1968 // App1 exists all the time. |
1920 // App2 is created when primary user is active and destroyed when secondary | 1969 // App2 is created when primary user is active and destroyed when secondary |
1921 // user is active. | 1970 // user is active. |
1922 // App3 created when secondary user is active. | 1971 // App3 created when secondary user is active. |
(...skipping 2334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4257 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, | 4306 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, |
4258 shelf_controller->auto_hide()); | 4307 shelf_controller->auto_hide()); |
4259 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count()); | 4308 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count()); |
4260 | 4309 |
4261 PrefService* prefs = profile()->GetTestingPrefService(); | 4310 PrefService* prefs = profile()->GetTestingPrefService(); |
4262 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal)); | 4311 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal)); |
4263 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment)); | 4312 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment)); |
4264 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal)); | 4313 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal)); |
4265 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior)); | 4314 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior)); |
4266 } | 4315 } |
OLD | NEW |