Index: ash/wm/panels/panel_layout_manager_unittest.cc |
diff --git a/ash/wm/panels/panel_layout_manager_unittest.cc b/ash/wm/panels/panel_layout_manager_unittest.cc |
index 5cc703beaed317c1596d5c88099935479e762284..6c138a6603808404b404d72f4092c8487843ac23 100644 |
--- a/ash/wm/panels/panel_layout_manager_unittest.cc |
+++ b/ash/wm/panels/panel_layout_manager_unittest.cc |
@@ -6,6 +6,7 @@ |
#include "ash/aura/wm_window_aura.h" |
#include "ash/common/ash_switches.h" |
+#include "ash/common/display/display_info.h" |
#include "ash/common/shelf/shelf_button.h" |
#include "ash/common/shelf/shelf_model.h" |
#include "ash/common/shelf/shelf_types.h" |
@@ -15,6 +16,7 @@ |
#include "ash/common/wm/mru_window_tracker.h" |
#include "ash/common/wm/window_state.h" |
#include "ash/common/wm_shell.h" |
+#include "ash/display/display_manager.h" |
#include "ash/screen_util.h" |
#include "ash/shelf/shelf.h" |
#include "ash/shelf/shelf_layout_manager.h" |
@@ -31,6 +33,7 @@ |
#include "base/compiler_specific.h" |
#include "base/i18n/rtl.h" |
#include "base/run_loop.h" |
+#include "base/strings/string_number_conversions.h" |
#include "ui/aura/client/aura_constants.h" |
#include "ui/aura/test/test_windows.h" |
#include "ui/aura/window.h" |
@@ -41,6 +44,24 @@ |
namespace ash { |
+namespace { |
+ |
+std::string ToDisplayName(int64_t id) { |
+ return "x-" + base::Int64ToString(id); |
+} |
+ |
+DisplayInfo CreateDisplayInfo(int64_t id, const gfx::Rect& bounds) { |
+ DisplayInfo info(id, ToDisplayName(id), false); |
+ info.SetBounds(bounds); |
+ return info; |
+} |
+ |
+DisplayManager* display_manager() { |
+ return Shell::GetInstance()->display_manager(); |
+} |
+ |
+} // namespace |
+ |
using aura::test::WindowIsAbove; |
class PanelLayoutManagerTest : public test::AshTestBase { |
@@ -285,6 +306,70 @@ TEST_P(PanelLayoutManagerTextDirectionTest, AddOnePanel) { |
EXPECT_NO_FATAL_FAILURE(IsCalloutAboveLauncherIcon(window.get())); |
} |
+// Tests for crashes during undocking. |
+// See https://crbug.com/632755 |
+TEST_F(PanelLayoutManagerTest, UndockTest) { |
+ std::vector<DisplayInfo> info_list; |
+ |
+ // Create the primary display info. |
+ DisplayInfo primary_display = |
+ CreateDisplayInfo(1, gfx::Rect(0, 0, 1280, 720)); |
+ // Create the secondary external display info. This will be docked display. |
+ DisplayInfo external_display_info = |
+ CreateDisplayInfo(2, gfx::Rect(0, 0, 1920, 1080)); |
+ |
+ info_list.push_back(external_display_info); |
+ // Docked state. |
+ display_manager()->OnNativeDisplaysChanged(info_list); |
+ |
+ // Create a panel in the docked state |
+ std::unique_ptr<aura::Window> p1_d2( |
+ CreatePanelWindow(gfx::Rect(1555, 800, 50, 50))); |
+ |
+ info_list.clear(); |
+ info_list.push_back(primary_display); |
+ |
+ // Undock and bring back the native device display as primary display. |
+ display_manager()->OnNativeDisplaysChanged(info_list); |
+} |
+ |
+// Tests for any crash during docking and then undocking. |
+// See https://crbug.com/632755 |
+TEST_F(PanelLayoutManagerTest, DockUndockTest) { |
+ std::vector<DisplayInfo> info_list; |
+ |
+ // Create the primary display info. |
+ DisplayInfo primary_display = |
+ CreateDisplayInfo(1, gfx::Rect(0, 0, 1280, 720)); |
oshima
2016/08/17 23:24:42
can you make this internal display?
const int64_t
|
+ |
+ info_list.push_back(primary_display); |
+ display_manager()->OnNativeDisplaysChanged(info_list); |
+ |
+ // Create a panel in the undocked state. |
+ std::unique_ptr<aura::Window> p1_d2( |
+ CreatePanelWindow(gfx::Rect(600, 200, 50, 50))); |
+ |
+ // Create the secondary external display info. This will be docked display. |
+ DisplayInfo external_display_info = |
+ CreateDisplayInfo(2, gfx::Rect(0, 0, 1920, 1080)); |
+ |
+ info_list.push_back(external_display_info); |
+ // Adding external Display |
+ display_manager()->OnNativeDisplaysChanged(info_list); |
+ |
+ info_list.clear(); |
+ info_list.push_back(external_display_info); |
+ |
+ // Docked state. |
+ display_manager()->OnNativeDisplaysChanged(info_list); |
+ |
+ info_list.clear(); |
+ info_list.push_back(primary_display); |
+ |
+ // Undock and bring back the native device display as primary display. |
+ display_manager()->OnNativeDisplaysChanged(info_list); |
+} |
+ |
// Tests that a created panel window is successfully aligned over a hidden |
// shelf icon. |
TEST_F(PanelLayoutManagerTest, PanelAlignsToHiddenLauncherIcon) { |