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

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: 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
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 exo::ShellSurface::SetApplicationId(widget->GetNativeWindow(),
khmel 2016/08/18 16:09:29 We use visibility event to activate Arc window bin
Mr4D (OOO till 08-26) 2016/08/18 21:00:12 You might want to add a comment for that as well?
khmel 2016/08/18 21:05:12 Agree, this is not clear :)
850 &window_app_id);
849 widget->Show(); 851 widget->Show();
850 widget->Activate(); 852 widget->Activate();
851 exo::ShellSurface::SetApplicationId(widget->GetNativeWindow(),
852 &window_app_id);
853 return widget; 853 return widget;
854 } 854 }
855 855
856 arc::mojom::AppInfo CreateAppInfo(const std::string& name, 856 arc::mojom::AppInfo CreateAppInfo(const std::string& name,
857 const std::string& activity, 857 const std::string& activity,
858 const std::string& package_name, 858 const std::string& package_name,
859 OrientationLock lock) { 859 OrientationLock lock) {
860 arc::mojom::AppInfo appinfo; 860 arc::mojom::AppInfo appinfo;
861 appinfo.name = name; 861 appinfo.name = name;
862 appinfo.package_name = package_name; 862 appinfo.package_name = package_name;
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after
1843 1843
1844 // Stopping bridge removes apps. 1844 // Stopping bridge removes apps.
1845 CreateArcWindow(window_app_id3); 1845 CreateArcWindow(window_app_id3);
1846 arc_test_.app_instance()->SendTaskCreated(3, arc_test_.fake_apps()[0]); 1846 arc_test_.app_instance()->SendTaskCreated(3, arc_test_.fake_apps()[0]);
1847 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); 1847 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id));
1848 arc_test_.StopArcInstance(); 1848 arc_test_.StopArcInstance();
1849 base::RunLoop().RunUntilIdle(); 1849 base::RunLoop().RunUntilIdle();
1850 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); 1850 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id));
1851 } 1851 }
1852 1852
1853 // Test race creation/deletion of Arc app.
1854 // TODO (khmel): Remove after moving everything to wayland protocol.
1855 TEST_F(ChromeLauncherControllerImplTest, ArcRaceCreateClose) {
1856 arc_test_.SetUp(profile());
1857 InitLauncherController();
1858
1859 const std::string arc_app_id1 =
1860 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
1861 const std::string arc_app_id2 =
1862 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]);
1863 SendListOfArcApps();
1864
1865 // Arc window created before and closed after mojom notification.
1866 std::string window_app_id1("org.chromium.arc.1");
1867 views::Widget* arc_window = CreateArcWindow(window_app_id1);
1868 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id1));
1869 ASSERT_TRUE(arc_window);
1870 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0]);
1871 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id1));
1872 arc_test_.app_instance()->SendTaskDestroyed(1);
1873 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id1));
1874 arc_window->Close();
1875 base::RunLoop().RunUntilIdle();
1876 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id1));
1877
1878 // Arc window created after and closed before mojom notification.
1879 std::string window_app_id2("org.chromium.arc.2");
1880 arc_test_.app_instance()->SendTaskCreated(2, arc_test_.fake_apps()[1]);
1881 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2));
1882 arc_window = CreateArcWindow(window_app_id2);
1883 ASSERT_TRUE(arc_window);
1884 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2));
1885 arc_window->Close();
1886 base::RunLoop().RunUntilIdle();
1887 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2));
1888 arc_test_.app_instance()->SendTaskDestroyed(2);
1889 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2));
1890 }
1891
1853 // Validate that Arc app is pinned correctly and pin is removed automatically 1892 // Validate that Arc app is pinned correctly and pin is removed automatically
1854 // once app is uninstalled. 1893 // once app is uninstalled.
1855 TEST_F(ChromeLauncherControllerImplTest, ArcAppPin) { 1894 TEST_F(ChromeLauncherControllerImplTest, ArcAppPin) {
1856 arc_test_.SetUp(profile()); 1895 arc_test_.SetUp(profile());
1857 InitLauncherController(); 1896 InitLauncherController();
1858 1897
1859 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); 1898 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
1860 1899
1861 SendListOfArcApps(); 1900 SendListOfArcApps();
1862 extension_service_->AddExtension(extension1_.get()); 1901 extension_service_->AddExtension(extension1_.get());
(...skipping 1797 matching lines...) Expand 10 before | Expand all | Expand 10 after
3660 EXPECT_FALSE(controller->rotation_locked()); 3699 EXPECT_FALSE(controller->rotation_locked());
3661 EXPECT_EQ(display::Display::ROTATE_0, 3700 EXPECT_EQ(display::Display::ROTATE_0,
3662 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); 3701 display::Screen::GetScreen()->GetPrimaryDisplay().rotation());
3663 3702
3664 NotifyOnTaskOrientationLockRequested(task_id_current_, 3703 NotifyOnTaskOrientationLockRequested(task_id_current_,
3665 OrientationLock::CURRENT); 3704 OrientationLock::CURRENT);
3666 EXPECT_TRUE(controller->rotation_locked()); 3705 EXPECT_TRUE(controller->rotation_locked());
3667 EXPECT_EQ(display::Display::ROTATE_0, 3706 EXPECT_EQ(display::Display::ROTATE_0,
3668 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); 3707 display::Screen::GetScreen()->GetPrimaryDisplay().rotation());
3669 } 3708 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698