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

Side by Side Diff: ash/display/display_controller_unittest.cc

Issue 17099003: Use primary display as hangout/gtalk broadcast window (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « ash/display/display_controller.cc ('k') | ui/aura/root_window_host_x11.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 }; 183 };
178 184
179 gfx::Display::Rotation GetStoredRotation(int64 id) { 185 gfx::Display::Rotation GetStoredRotation(int64 id) {
180 return Shell::GetInstance()->display_manager()->GetDisplayInfo(id).rotation(); 186 return Shell::GetInstance()->display_manager()->GetDisplayInfo(id).rotation();
181 } 187 }
182 188
183 float GetStoredUIScale(int64 id) { 189 float GetStoredUIScale(int64 id) {
184 return Shell::GetInstance()->display_manager()->GetDisplayInfo(id).ui_scale(); 190 return Shell::GetInstance()->display_manager()->GetDisplayInfo(id).ui_scale();
185 } 191 }
186 192
193 #if defined(USE_X11)
194 void GetPrimaryAndSeconary(aura::RootWindow** primary,
195 aura::RootWindow** secondary) {
196 *primary = Shell::GetPrimaryRootWindow();
197 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
198 *secondary = root_windows[0] == *primary ? root_windows[1] : root_windows[0];
199 }
200
201 std::string GetXWindowName(aura::RootWindow* window) {
202 char* name = NULL;
203 XFetchName(ui::GetXDisplay(), window->GetAcceleratedWidget(), &name);
204 return std::string(name);
205 }
206 #endif
207
187 } // namespace 208 } // namespace
188 209
189 typedef test::AshTestBase DisplayControllerTest; 210 typedef test::AshTestBase DisplayControllerTest;
190 211
191 TEST_F(DisplayControllerShutdownTest, Shutdown) { 212 TEST_F(DisplayControllerShutdownTest, Shutdown) {
192 if (!SupportsMultipleDisplays()) 213 if (!SupportsMultipleDisplays())
193 return; 214 return;
194 215
195 UpdateDisplay("444x333, 200x200"); 216 UpdateDisplay("444x333, 200x200");
196 } 217 }
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 generator.MoveMouseToInHost(599, 0); 947 generator.MoveMouseToInHost(599, 0);
927 EXPECT_EQ("299,449", event_handler.GetLocationAndReset()); 948 EXPECT_EQ("299,449", event_handler.GetLocationAndReset());
928 generator.MoveMouseToInHost(599, 399); 949 generator.MoveMouseToInHost(599, 399);
929 EXPECT_EQ("0,449", event_handler.GetLocationAndReset()); 950 EXPECT_EQ("0,449", event_handler.GetLocationAndReset());
930 generator.MoveMouseToInHost(0, 399); 951 generator.MoveMouseToInHost(0, 399);
931 EXPECT_EQ("0,0", event_handler.GetLocationAndReset()); 952 EXPECT_EQ("0,0", event_handler.GetLocationAndReset());
932 953
933 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); 954 Shell::GetInstance()->RemovePreTargetHandler(&event_handler);
934 } 955 }
935 956
957 #if defined(USE_X11)
958 TEST_F(DisplayControllerTest, XWidowNameForRootWindow) {
959 EXPECT_EQ("aura_root_0", GetXWindowName(Shell::GetPrimaryRootWindow()));
960
961 // Multiple display.
962 UpdateDisplay("200x200,300x300");
963 aura::RootWindow* primary, *secondary;
964 GetPrimaryAndSeconary(&primary, &secondary);
965 EXPECT_EQ("aura_root_0", GetXWindowName(primary));
966 EXPECT_EQ("aura_root_x", GetXWindowName(secondary));
967
968 // Swap primary.
969 primary = secondary = NULL;
970 Shell::GetInstance()->display_controller()->SwapPrimaryDisplay();
971 GetPrimaryAndSeconary(&primary, &secondary);
972 EXPECT_EQ("aura_root_0", GetXWindowName(primary));
973 EXPECT_EQ("aura_root_x", GetXWindowName(secondary));
974
975 // Switching back to single display.
976 UpdateDisplay("300x400");
977 EXPECT_EQ("aura_root_0", GetXWindowName(Shell::GetPrimaryRootWindow()));
978 }
979 #endif
980
936 } // namespace test 981 } // namespace test
937 } // namespace ash 982 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_controller.cc ('k') | ui/aura/root_window_host_x11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698