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

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

Issue 2259403002: arc: Fix crash on window close (on close race condition). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: 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 845 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 EXPECT_EQ(pin_status, GetPinnedAppStatus()); 856 EXPECT_EQ(pin_status, GetPinnedAppStatus());
857 } 857 }
858 858
859 // Creates app window and set optional Arc application id. 859 // Creates app window and set optional Arc application id.
860 views::Widget* CreateArcWindow(std::string& window_app_id) { 860 views::Widget* CreateArcWindow(std::string& window_app_id) {
861 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 861 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
862 params.bounds = gfx::Rect(5, 5, 20, 20); 862 params.bounds = gfx::Rect(5, 5, 20, 20);
863 params.context = GetContext(); 863 params.context = GetContext();
864 views::Widget* widget = new views::Widget(); 864 views::Widget* widget = new views::Widget();
865 widget->Init(params); 865 widget->Init(params);
866 // Set Arc id before showing the window to be recognized in
867 // ArcAppWindowLauncherController.
868 exo::ShellSurface::SetApplicationId(widget->GetNativeWindow(),
869 &window_app_id);
866 widget->Show(); 870 widget->Show();
867 widget->Activate(); 871 widget->Activate();
868 exo::ShellSurface::SetApplicationId(widget->GetNativeWindow(),
869 &window_app_id);
870 return widget; 872 return widget;
871 } 873 }
872 874
873 arc::mojom::AppInfo CreateAppInfo(const std::string& name, 875 arc::mojom::AppInfo CreateAppInfo(const std::string& name,
874 const std::string& activity, 876 const std::string& activity,
875 const std::string& package_name, 877 const std::string& package_name,
876 OrientationLock lock) { 878 OrientationLock lock) {
877 arc::mojom::AppInfo appinfo; 879 arc::mojom::AppInfo appinfo;
878 appinfo.name = name; 880 appinfo.name = name;
879 appinfo.package_name = package_name; 881 appinfo.package_name = package_name;
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after
1861 1863
1862 // Stopping bridge removes apps. 1864 // Stopping bridge removes apps.
1863 CreateArcWindow(window_app_id3); 1865 CreateArcWindow(window_app_id3);
1864 arc_test_.app_instance()->SendTaskCreated(3, arc_test_.fake_apps()[0]); 1866 arc_test_.app_instance()->SendTaskCreated(3, arc_test_.fake_apps()[0]);
1865 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); 1867 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id));
1866 arc_test_.StopArcInstance(); 1868 arc_test_.StopArcInstance();
1867 base::RunLoop().RunUntilIdle(); 1869 base::RunLoop().RunUntilIdle();
1868 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); 1870 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id));
1869 } 1871 }
1870 1872
1873 // Test race creation/deletion of Arc app.
1874 // TODO (khmel): Remove after moving everything to wayland protocol.
1875 TEST_F(ChromeLauncherControllerImplTest, ArcRaceCreateClose) {
1876 arc_test_.SetUp(profile());
1877 InitLauncherController();
1878
1879 const std::string arc_app_id1 =
1880 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
1881 const std::string arc_app_id2 =
1882 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]);
1883 SendListOfArcApps();
1884
1885 // Arc window created before and closed after mojom notification.
1886 std::string window_app_id1("org.chromium.arc.1");
1887 views::Widget* arc_window = CreateArcWindow(window_app_id1);
1888 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id1));
1889 ASSERT_TRUE(arc_window);
1890 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0]);
1891 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id1));
1892 arc_test_.app_instance()->SendTaskDestroyed(1);
1893 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id1));
1894 arc_window->Close();
1895 base::RunLoop().RunUntilIdle();
1896 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id1));
1897
1898 // Arc window created after and closed before mojom notification.
1899 std::string window_app_id2("org.chromium.arc.2");
1900 arc_test_.app_instance()->SendTaskCreated(2, arc_test_.fake_apps()[1]);
1901 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2));
1902 arc_window = CreateArcWindow(window_app_id2);
1903 ASSERT_TRUE(arc_window);
1904 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2));
1905 arc_window->Close();
1906 base::RunLoop().RunUntilIdle();
1907 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2));
1908 arc_test_.app_instance()->SendTaskDestroyed(2);
1909 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2));
1910 }
1911
1871 // Validate that Arc app is pinned correctly and pin is removed automatically 1912 // Validate that Arc app is pinned correctly and pin is removed automatically
1872 // once app is uninstalled. 1913 // once app is uninstalled.
1873 TEST_F(ChromeLauncherControllerImplTest, ArcAppPin) { 1914 TEST_F(ChromeLauncherControllerImplTest, ArcAppPin) {
1874 arc_test_.SetUp(profile()); 1915 arc_test_.SetUp(profile());
1875 InitLauncherController(); 1916 InitLauncherController();
1876 1917
1877 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); 1918 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
1878 1919
1879 SendListOfArcApps(); 1920 SendListOfArcApps();
1880 extension_service_->AddExtension(extension1_.get()); 1921 extension_service_->AddExtension(extension1_.get());
(...skipping 1821 matching lines...) Expand 10 before | Expand all | Expand 10 after
3702 EXPECT_FALSE(controller->rotation_locked()); 3743 EXPECT_FALSE(controller->rotation_locked());
3703 EXPECT_EQ(display::Display::ROTATE_0, 3744 EXPECT_EQ(display::Display::ROTATE_0,
3704 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); 3745 display::Screen::GetScreen()->GetPrimaryDisplay().rotation());
3705 3746
3706 NotifyOnTaskOrientationLockRequested(task_id_current_, 3747 NotifyOnTaskOrientationLockRequested(task_id_current_,
3707 OrientationLock::CURRENT); 3748 OrientationLock::CURRENT);
3708 EXPECT_TRUE(controller->rotation_locked()); 3749 EXPECT_TRUE(controller->rotation_locked());
3709 EXPECT_EQ(display::Display::ROTATE_0, 3750 EXPECT_EQ(display::Display::ROTATE_0,
3710 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); 3751 display::Screen::GetScreen()->GetPrimaryDisplay().rotation());
3711 } 3752 }
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