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

Side by Side Diff: ash/test/display_manager_test_api.cc

Issue 11363124: Move DisplayManager and DisplayChangeObserverX11 from aura to ash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix rebase Created 8 years, 1 month 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/test/display_manager_test_api.h ('k') | ash/test/multi_display_manager_test_api.h » ('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/test/multi_display_manager_test_api.h" 5 #include "ash/test/display_manager_test_api.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ash/display/multi_display_manager.h" 9 #include "ash/display/display_manager.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
11 #include "base/string_split.h" 11 #include "base/string_split.h"
12 #include "ui/aura/display_util.h"
12 #include "ui/aura/root_window.h" 13 #include "ui/aura/root_window.h"
13 #include "ui/gfx/display.h" 14 #include "ui/gfx/display.h"
14 15
15 namespace ash { 16 namespace ash {
16 namespace test { 17 namespace test {
17 namespace { 18 namespace {
18 19
19 std::vector<gfx::Display> CreateDisplaysFromString( 20 std::vector<gfx::Display> CreateDisplaysFromString(
20 const std::string specs) { 21 const std::string specs) {
21 std::vector<gfx::Display> displays; 22 std::vector<gfx::Display> displays;
22 std::vector<std::string> parts; 23 std::vector<std::string> parts;
23 base::SplitString(specs, ',', &parts); 24 base::SplitString(specs, ',', &parts);
24 for (std::vector<std::string>::const_iterator iter = parts.begin(); 25 for (std::vector<std::string>::const_iterator iter = parts.begin();
25 iter != parts.end(); ++iter) { 26 iter != parts.end(); ++iter) {
26 displays.push_back(aura::DisplayManager::CreateDisplayFromSpec(*iter)); 27 displays.push_back(aura::CreateDisplayFromSpec(*iter));
27 } 28 }
28 return displays; 29 return displays;
29 } 30 }
30 31
31 } // namespace 32 } // namespace
32 33
33 MultiDisplayManagerTestApi::MultiDisplayManagerTestApi( 34 DisplayManagerTestApi::DisplayManagerTestApi(
34 internal::MultiDisplayManager* display_manager) 35 internal::DisplayManager* display_manager)
35 : display_manager_(display_manager) { 36 : display_manager_(display_manager) {
36 } 37 }
37 38
38 MultiDisplayManagerTestApi::~MultiDisplayManagerTestApi() {} 39 DisplayManagerTestApi::~DisplayManagerTestApi() {}
39 40
40 void MultiDisplayManagerTestApi::UpdateDisplay( 41 void DisplayManagerTestApi::UpdateDisplay(
41 const std::string& display_specs) { 42 const std::string& display_specs) {
42 std::vector<gfx::Display> displays = CreateDisplaysFromString(display_specs); 43 std::vector<gfx::Display> displays = CreateDisplaysFromString(display_specs);
43 display_manager_->SetDisplayIdsForTest(&displays); 44 display_manager_->SetDisplayIdsForTest(&displays);
44 display_manager_->OnNativeDisplaysChanged(displays); 45 display_manager_->OnNativeDisplaysChanged(displays);
45 46
46 bool is_host_origin_set = false; 47 bool is_host_origin_set = false;
47 for (size_t i = 0; i < displays.size(); ++i) { 48 for (size_t i = 0; i < displays.size(); ++i) {
48 if (displays[i].bounds_in_pixel().origin() != gfx::Point(0, 0)) { 49 if (displays[i].bounds_in_pixel().origin() != gfx::Point(0, 0)) {
49 is_host_origin_set = true; 50 is_host_origin_set = true;
50 break; 51 break;
51 } 52 }
52 } 53 }
53 54
54 // On non-testing environment, when a secondary display is connected, a new 55 // On non-testing environment, when a secondary display is connected, a new
55 // native (i.e. X) window for the display is always created below the 56 // native (i.e. X) window for the display is always created below the
56 // previous one for GPU performance reasons. Try to emulate the behavior 57 // previous one for GPU performance reasons. Try to emulate the behavior
57 // unless host origins are explicitly set. 58 // unless host origins are explicitly set.
58 if (!is_host_origin_set) { 59 if (!is_host_origin_set) {
59 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 60 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
60 int next_y = 0; 61 int next_y = 0;
61 for (size_t i = 0; i < root_windows.size(); ++i) { 62 for (size_t i = 0; i < root_windows.size(); ++i) {
62 const gfx::Size size = root_windows[i]->GetHostSize(); 63 const gfx::Size size = root_windows[i]->GetHostSize();
63 root_windows[i]->SetHostBounds(gfx::Rect(gfx::Point(0, next_y), size)); 64 root_windows[i]->SetHostBounds(gfx::Rect(gfx::Point(0, next_y), size));
64 next_y += size.height(); 65 next_y += size.height();
65 } 66 }
66 } 67 }
67 } 68 }
68 69
69
70 } // namespace test 70 } // namespace test
71 } // namespace ash 71 } // namespace ash
OLDNEW
« no previous file with comments | « ash/test/display_manager_test_api.h ('k') | ash/test/multi_display_manager_test_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698