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

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

Issue 2747983002: arc: Fix crash on deferred app launch. (Closed)
Patch Set: refactored Created 3 years, 9 months 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
« no previous file with comments | « chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1914 matching lines...) Expand 10 before | Expand all | Expand 10 after
1925 1925
1926 const arc::FakeAppInstance::Request* request1 = 1926 const arc::FakeAppInstance::Request* request1 =
1927 arc_test_.app_instance()->launch_requests()[0].get(); 1927 arc_test_.app_instance()->launch_requests()[0].get();
1928 const arc::FakeAppInstance::Request* request2 = 1928 const arc::FakeAppInstance::Request* request2 =
1929 arc_test_.app_instance()->launch_requests()[1].get(); 1929 arc_test_.app_instance()->launch_requests()[1].get();
1930 1930
1931 EXPECT_TRUE((request1->IsForApp(app2) && request2->IsForApp(app3)) || 1931 EXPECT_TRUE((request1->IsForApp(app2) && request2->IsForApp(app3)) ||
1932 (request1->IsForApp(app3) && request2->IsForApp(app2))); 1932 (request1->IsForApp(app3) && request2->IsForApp(app2)));
1933 } 1933 }
1934 1934
1935 // Test that validates deferred controler does not override active app
msw 2017/03/14 20:28:08 nit: consider "// Ensure the deferred controller d
khmel 2017/03/14 20:32:09 Thanks for ready to use text :)
1936 // controller.
1937 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcDeferredLaunchForActiveApp) {
1938 RecreateChromeLauncher();
1939 SendListOfArcApps();
1940 arc_test_.StopArcInstance();
1941
1942 const arc::mojom::AppInfo& app = arc_test_.fake_apps()[0];
1943 const std::string app_id = ArcAppTest::GetAppId(app);
1944
1945 launcher_controller_->PinAppWithID(app_id);
1946 EXPECT_TRUE(launcher_controller_->IsAppPinned(app_id));
1947 const ash::ShelfID shelf_id =
1948 launcher_controller_->GetShelfIDForAppID(app_id);
1949 EXPECT_NE(ash::kInvalidShelfID, shelf_id);
1950
1951 int item_index = model_->ItemIndexByID(shelf_id);
1952 ASSERT_GE(item_index, 0);
1953
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 // Play Store app is ARC app that might be represented by native Chrome
1958 // platform app.
1959 AppWindowLauncherItemController* app_controller =
1960 new ExtensionAppWindowLauncherItemController(app_id, "",
1961 launcher_controller_.get());
1962 launcher_controller_->SetItemController(shelf_id, app_controller);
1963 launcher_controller_->SetItemStatus(shelf_id, ash::STATUS_RUNNING);
1964
1965 // This launch request should be ignored in case of active app.
1966 arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON);
1967 EXPECT_FALSE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id));
1968
1969 // Close app but shortcut should exist.
1970 launcher_controller_->CloseLauncherItem(shelf_id);
1971 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(app_id));
1972
1973 // This should switch shelf item into active state.
msw 2017/03/14 20:28:08 nit: Does 'active' here contradict the 'STATUS_CLO
khmel 2017/03/14 20:32:09 nice catch.
1974 item_index = model_->ItemIndexByID(shelf_id);
1975 ASSERT_GE(item_index, 0);
1976 EXPECT_EQ(model_->items()[item_index].status, ash::STATUS_CLOSED);
1977 EXPECT_EQ(model_->items()[item_index].type, ash::TYPE_APP_SHORTCUT);
1978
1979 // Now launch request should not be ignored.
1980 arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON);
1981 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id));
1982 }
1983
1935 TEST_P(ChromeLauncherControllerImplMultiProfileWithArcTest, ArcMultiUser) { 1984 TEST_P(ChromeLauncherControllerImplMultiProfileWithArcTest, ArcMultiUser) {
1936 SendListOfArcApps(); 1985 SendListOfArcApps();
1937 1986
1938 InitLauncherController(); 1987 InitLauncherController();
1939 SetLauncherControllerHelper(new TestLauncherControllerHelper); 1988 SetLauncherControllerHelper(new TestLauncherControllerHelper);
1940 1989
1941 // App1 exists all the time. 1990 // App1 exists all the time.
1942 // App2 is created when primary user is active and destroyed when secondary 1991 // App2 is created when primary user is active and destroyed when secondary
1943 // user is active. 1992 // user is active.
1944 // App3 created when secondary user is active. 1993 // App3 created when secondary user is active.
(...skipping 2357 matching lines...) Expand 10 before | Expand all | Expand 10 after
4302 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, 4351 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
4303 shelf_controller->auto_hide()); 4352 shelf_controller->auto_hide());
4304 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count()); 4353 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count());
4305 4354
4306 PrefService* prefs = profile()->GetTestingPrefService(); 4355 PrefService* prefs = profile()->GetTestingPrefService();
4307 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal)); 4356 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal));
4308 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment)); 4357 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment));
4309 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal)); 4358 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal));
4310 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior)); 4359 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior));
4311 } 4360 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698