Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/display/display_controller.h" | 5 #include "ash/display/display_controller.h" |
| 6 | 6 |
| 7 #include "ash/display/display_info.h" | 7 #include "ash/display/display_info.h" |
| 8 #include "ash/display/display_manager.h" | 8 #include "ash/display/display_manager.h" |
| 9 #include "ash/launcher/launcher.h" | 9 #include "ash/launcher/launcher.h" |
| 10 #include "ash/screen_ash.h" | 10 #include "ash/screen_ash.h" |
| 11 #include "ash/shelf/shelf_widget.h" | 11 #include "ash/shelf/shelf_widget.h" |
| 12 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 13 #include "ash/test/ash_test_base.h" | 13 #include "ash/test/ash_test_base.h" |
| 14 #include "ash/test/cursor_manager_test_api.h" | 14 #include "ash/test/cursor_manager_test_api.h" |
| 15 #include "ui/aura/env.h" | 15 #include "ui/aura/env.h" |
| 16 #include "ui/aura/root_window.h" | 16 #include "ui/aura/root_window.h" |
| 17 #include "ui/aura/test/event_generator.h" | 17 #include "ui/aura/test/event_generator.h" |
| 18 #include "ui/aura/window_tracker.h" | 18 #include "ui/aura/window_tracker.h" |
| 19 #include "ui/base/events/event_handler.h" | 19 #include "ui/base/events/event_handler.h" |
| 20 #include "ui/gfx/display.h" | 20 #include "ui/gfx/display.h" |
| 21 #include "ui/gfx/screen.h" | 21 #include "ui/gfx/screen.h" |
| 22 #include "ui/views/widget/widget.h" | 22 #include "ui/views/widget/widget.h" |
| 23 | 23 |
| 24 #if defined(USE_X11) | |
| 25 #include "ui/base/x/x11_util.h" | |
| 26 #include <X11/Xlib.h> | |
| 27 #undef RootWindow | |
| 28 #endif | |
| 29 | |
| 24 namespace ash { | 30 namespace ash { |
| 25 namespace test { | 31 namespace test { |
| 26 namespace { | 32 namespace { |
| 27 | 33 |
| 28 const char kDesktopBackgroundView[] = "DesktopBackgroundView"; | 34 const char kDesktopBackgroundView[] = "DesktopBackgroundView"; |
| 29 | 35 |
| 30 class TestObserver : public DisplayController::Observer { | 36 class TestObserver : public DisplayController::Observer { |
| 31 public: | 37 public: |
| 32 TestObserver() : changing_count_(0), changed_count_(0) { | 38 TestObserver() : changing_count_(0), changed_count_(0) { |
| 33 Shell::GetInstance()->display_controller()->AddObserver(this); | 39 Shell::GetInstance()->display_controller()->AddObserver(this); |
| (...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 926 generator.MoveMouseToInHost(599, 0); | 932 generator.MoveMouseToInHost(599, 0); |
| 927 EXPECT_EQ("299,449", event_handler.GetLocationAndReset()); | 933 EXPECT_EQ("299,449", event_handler.GetLocationAndReset()); |
| 928 generator.MoveMouseToInHost(599, 399); | 934 generator.MoveMouseToInHost(599, 399); |
| 929 EXPECT_EQ("0,449", event_handler.GetLocationAndReset()); | 935 EXPECT_EQ("0,449", event_handler.GetLocationAndReset()); |
| 930 generator.MoveMouseToInHost(0, 399); | 936 generator.MoveMouseToInHost(0, 399); |
| 931 EXPECT_EQ("0,0", event_handler.GetLocationAndReset()); | 937 EXPECT_EQ("0,0", event_handler.GetLocationAndReset()); |
| 932 | 938 |
| 933 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); | 939 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |
| 934 } | 940 } |
| 935 | 941 |
| 942 void GetPrimaryAndSeconary(aura::RootWindow** primary, | |
| 943 aura::RootWindow** secondary) { | |
| 944 *primary = Shell::GetPrimaryRootWindow(); | |
| 945 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | |
| 946 *secondary = root_windows[0] == *primary ? root_windows[1] : root_windows[0]; | |
|
Josh Horwich
2013/06/14 22:44:03
I know that right now the function will only be in
oshima
2013/06/14 23:10:01
For single display case, we should just use Shell:
| |
| 947 } | |
| 948 | |
| 949 std::string GetXWindowName(aura::RootWindow* window) { | |
| 950 char* name = NULL; | |
| 951 XFetchName(ui::GetXDisplay(), window->GetAcceleratedWidget(), &name); | |
| 952 // ASSERT_TRUE(!!name); | |
|
oshima
2013/06/14 23:10:01
I forgot to remove this as well. Removed.
| |
| 953 return std::string(name); | |
| 954 } | |
|
oshima
2013/06/14 23:10:01
I also moved this to anonymous namespace.
| |
| 955 | |
| 956 #if defined(USE_X11) | |
| 957 TEST_F(DisplayControllerTest, XWidowNameForRootWindow) { | |
| 958 EXPECT_EQ("aura_root_0", GetXWindowName(Shell::GetPrimaryRootWindow())); | |
| 959 | |
| 960 // Multiple display. | |
| 961 UpdateDisplay("200x200,300x300"); | |
| 962 aura::RootWindow* primary, *secondary; | |
| 963 GetPrimaryAndSeconary(&primary, &secondary); | |
| 964 EXPECT_EQ("aura_root_0", GetXWindowName(primary)); | |
| 965 EXPECT_EQ("aura_root_x", GetXWindowName(secondary)); | |
| 966 | |
| 967 // Swap primary. | |
| 968 Shell::GetInstance()->display_controller()->SwapPrimaryDisplay(); | |
| 969 GetPrimaryAndSeconary(&primary, &secondary); | |
| 970 EXPECT_EQ("aura_root_0", GetXWindowName(primary)); | |
| 971 EXPECT_EQ("aura_root_x", GetXWindowName(secondary)); | |
|
Josh Horwich
2013/06/14 22:44:03
Would it make sense to save the pointers from befo
oshima
2013/06/14 23:10:01
Swapping display actually doesn't change the root
| |
| 972 | |
| 973 // Switching back to single display. | |
| 974 UpdateDisplay("300x400"); | |
| 975 EXPECT_EQ("aura_root_0", GetXWindowName(Shell::GetPrimaryRootWindow())); | |
| 976 } | |
| 977 #endif | |
| 978 | |
| 936 } // namespace test | 979 } // namespace test |
| 937 } // namespace ash | 980 } // namespace ash |
| OLD | NEW |