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

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

Issue 2256273003: arc: Fix crash on window close (on close race condition). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment added Created 4 years, 4 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_window_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 828 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 EXPECT_EQ(pin_status, GetPinnedAppStatus()); 839 EXPECT_EQ(pin_status, GetPinnedAppStatus());
840 } 840 }
841 841
842 // Creates app window and set optional Arc application id. 842 // Creates app window and set optional Arc application id.
843 views::Widget* CreateArcWindow(std::string& window_app_id) { 843 views::Widget* CreateArcWindow(std::string& window_app_id) {
844 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 844 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
845 params.bounds = gfx::Rect(5, 5, 20, 20); 845 params.bounds = gfx::Rect(5, 5, 20, 20);
846 params.context = GetContext(); 846 params.context = GetContext();
847 views::Widget* widget = new views::Widget(); 847 views::Widget* widget = new views::Widget();
848 widget->Init(params); 848 widget->Init(params);
849 // Set Arc id before showing the window to be recognized in
850 // ArcAppWindowLauncherController.
851 exo::ShellSurface::SetApplicationId(widget->GetNativeWindow(),
852 &window_app_id);
849 widget->Show(); 853 widget->Show();
850 widget->Activate(); 854 widget->Activate();
851 exo::ShellSurface::SetApplicationId(widget->GetNativeWindow(),
852 &window_app_id);
853 return widget; 855 return widget;
854 } 856 }
855 857
856 arc::mojom::AppInfo CreateAppInfo(const std::string& name, 858 arc::mojom::AppInfo CreateAppInfo(const std::string& name,
857 const std::string& activity, 859 const std::string& activity,
858 const std::string& package_name, 860 const std::string& package_name,
859 OrientationLock lock) { 861 OrientationLock lock) {
860 arc::mojom::AppInfo appinfo; 862 arc::mojom::AppInfo appinfo;
861 appinfo.name = name; 863 appinfo.name = name;
862 appinfo.package_name = package_name; 864 appinfo.package_name = package_name;
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after
1843 1845
1844 // Stopping bridge removes apps. 1846 // Stopping bridge removes apps.
1845 CreateArcWindow(window_app_id3); 1847 CreateArcWindow(window_app_id3);
1846 arc_test_.app_instance()->SendTaskCreated(3, arc_test_.fake_apps()[0]); 1848 arc_test_.app_instance()->SendTaskCreated(3, arc_test_.fake_apps()[0]);
1847 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); 1849 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id));
1848 arc_test_.StopArcInstance(); 1850 arc_test_.StopArcInstance();
1849 base::RunLoop().RunUntilIdle(); 1851 base::RunLoop().RunUntilIdle();
1850 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); 1852 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id));
1851 } 1853 }
1852 1854
1855 // Test race creation/deletion of Arc app.
1856 // TODO (khmel): Remove after moving everything to wayland protocol.
1857 TEST_F(ChromeLauncherControllerImplTest, ArcRaceCreateClose) {
1858 arc_test_.SetUp(profile());
1859 InitLauncherController();
1860
1861 const std::string arc_app_id1 =
1862 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
1863 const std::string arc_app_id2 =
1864 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]);
1865 SendListOfArcApps();
1866
1867 // Arc window created before and closed after mojom notification.
1868 std::string window_app_id1("org.chromium.arc.1");
1869 views::Widget* arc_window = CreateArcWindow(window_app_id1);
1870 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id1));
1871 ASSERT_TRUE(arc_window);
1872 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0]);
1873 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id1));
1874 arc_test_.app_instance()->SendTaskDestroyed(1);
1875 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id1));
1876 arc_window->Close();
1877 base::RunLoop().RunUntilIdle();
1878 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id1));
1879
1880 // Arc window created after and closed before mojom notification.
1881 std::string window_app_id2("org.chromium.arc.2");
1882 arc_test_.app_instance()->SendTaskCreated(2, arc_test_.fake_apps()[1]);
1883 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2));
1884 arc_window = CreateArcWindow(window_app_id2);
1885 ASSERT_TRUE(arc_window);
1886 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2));
1887 arc_window->Close();
1888 base::RunLoop().RunUntilIdle();
1889 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2));
1890 arc_test_.app_instance()->SendTaskDestroyed(2);
1891 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2));
1892 }
1893
1853 // Validate that Arc app is pinned correctly and pin is removed automatically 1894 // Validate that Arc app is pinned correctly and pin is removed automatically
1854 // once app is uninstalled. 1895 // once app is uninstalled.
1855 TEST_F(ChromeLauncherControllerImplTest, ArcAppPin) { 1896 TEST_F(ChromeLauncherControllerImplTest, ArcAppPin) {
1856 arc_test_.SetUp(profile()); 1897 arc_test_.SetUp(profile());
1857 InitLauncherController(); 1898 InitLauncherController();
1858 1899
1859 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); 1900 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
1860 1901
1861 SendListOfArcApps(); 1902 SendListOfArcApps();
1862 extension_service_->AddExtension(extension1_.get()); 1903 extension_service_->AddExtension(extension1_.get());
(...skipping 1797 matching lines...) Expand 10 before | Expand all | Expand 10 after
3660 EXPECT_FALSE(controller->rotation_locked()); 3701 EXPECT_FALSE(controller->rotation_locked());
3661 EXPECT_EQ(display::Display::ROTATE_0, 3702 EXPECT_EQ(display::Display::ROTATE_0,
3662 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); 3703 display::Screen::GetScreen()->GetPrimaryDisplay().rotation());
3663 3704
3664 NotifyOnTaskOrientationLockRequested(task_id_current_, 3705 NotifyOnTaskOrientationLockRequested(task_id_current_,
3665 OrientationLock::CURRENT); 3706 OrientationLock::CURRENT);
3666 EXPECT_TRUE(controller->rotation_locked()); 3707 EXPECT_TRUE(controller->rotation_locked());
3667 EXPECT_EQ(display::Display::ROTATE_0, 3708 EXPECT_EQ(display::Display::ROTATE_0,
3668 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); 3709 display::Screen::GetScreen()->GetPrimaryDisplay().rotation());
3669 } 3710 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698