| OLD | NEW |
| 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 "ash/display/root_window_transformers.h" | 5 #include "ash/display/root_window_transformers.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/host/root_window_transformer.h" | 9 #include "ash/host/root_window_transformer.h" |
| 10 #include "ash/magnifier/magnification_controller.h" | 10 #include "ash/magnifier/magnification_controller.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 float touch_radius_y_; | 101 float touch_radius_y_; |
| 102 float scroll_x_offset_; | 102 float scroll_x_offset_; |
| 103 float scroll_y_offset_; | 103 float scroll_y_offset_; |
| 104 float scroll_x_offset_ordinal_; | 104 float scroll_x_offset_ordinal_; |
| 105 float scroll_y_offset_ordinal_; | 105 float scroll_y_offset_ordinal_; |
| 106 | 106 |
| 107 DISALLOW_COPY_AND_ASSIGN(TestEventHandler); | 107 DISALLOW_COPY_AND_ASSIGN(TestEventHandler); |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 gfx::Display::Rotation GetStoredRotation(int64 id) { | 110 gfx::Display::Rotation GetStoredRotation(int64 id) { |
| 111 return Shell::GetInstance()->display_manager()->GetDisplayInfo(id).rotation(); | 111 return Shell::GetInstance()->display_manager()->GetDisplayInfo(id).Rotation( |
| 112 gfx::Display::ROTATION_SOURCE_ACTIVE); |
| 112 } | 113 } |
| 113 | 114 |
| 114 float GetStoredUIScale(int64 id) { | 115 float GetStoredUIScale(int64 id) { |
| 115 return Shell::GetInstance()->display_manager()->GetDisplayInfo(id). | 116 return Shell::GetInstance()->display_manager()->GetDisplayInfo(id). |
| 116 GetEffectiveUIScale(); | 117 GetEffectiveUIScale(); |
| 117 } | 118 } |
| 118 | 119 |
| 119 } // namespace | 120 } // namespace |
| 120 | 121 |
| 121 typedef test::AshTestBase RootWindowTransformersTest; | 122 typedef test::AshTestBase RootWindowTransformersTest; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 EXPECT_EQ("120,0 150x200", | 156 EXPECT_EQ("120,0 150x200", |
| 156 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); | 157 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
| 157 generator1.MoveMouseToInHost(40, 80); | 158 generator1.MoveMouseToInHost(40, 80); |
| 158 EXPECT_EQ("50,90", event_handler.GetLocationAndReset()); | 159 EXPECT_EQ("50,90", event_handler.GetLocationAndReset()); |
| 159 EXPECT_EQ("50,90", | 160 EXPECT_EQ("50,90", |
| 160 aura::Env::GetInstance()->last_mouse_location().ToString()); | 161 aura::Env::GetInstance()->last_mouse_location().ToString()); |
| 161 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display1.id())); | 162 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display1.id())); |
| 162 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id)); | 163 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id)); |
| 163 magnifier->SetEnabled(false); | 164 magnifier->SetEnabled(false); |
| 164 | 165 |
| 165 display_manager->SetDisplayRotation(display1.id(), | 166 display_manager->SetDisplayRotation(display1.id(), gfx::Display::ROTATE_90, |
| 166 gfx::Display::ROTATE_90); | 167 gfx::Display::ROTATION_SOURCE_ACTIVE); |
| 167 // Move the cursor to the center of the first root window. | 168 // Move the cursor to the center of the first root window. |
| 168 generator1.MoveMouseToInHost(59, 100); | 169 generator1.MoveMouseToInHost(59, 100); |
| 169 | 170 |
| 170 magnifier->SetEnabled(true); | 171 magnifier->SetEnabled(true); |
| 171 EXPECT_EQ(2.0f, magnifier->GetScale()); | 172 EXPECT_EQ(2.0f, magnifier->GetScale()); |
| 172 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); | 173 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); |
| 173 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); | 174 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); |
| 174 EXPECT_EQ("200,0 150x200", | 175 EXPECT_EQ("200,0 150x200", |
| 175 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); | 176 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
| 176 generator1.MoveMouseToInHost(39, 120); | 177 generator1.MoveMouseToInHost(39, 120); |
| 177 EXPECT_EQ("110,70", event_handler.GetLocationAndReset()); | 178 EXPECT_EQ("110,70", event_handler.GetLocationAndReset()); |
| 178 EXPECT_EQ("110,70", | 179 EXPECT_EQ("110,70", |
| 179 aura::Env::GetInstance()->last_mouse_location().ToString()); | 180 aura::Env::GetInstance()->last_mouse_location().ToString()); |
| 180 EXPECT_EQ(gfx::Display::ROTATE_90, GetStoredRotation(display1.id())); | 181 EXPECT_EQ(gfx::Display::ROTATE_90, GetStoredRotation(display1.id())); |
| 181 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id)); | 182 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id)); |
| 182 magnifier->SetEnabled(false); | 183 magnifier->SetEnabled(false); |
| 183 | 184 |
| 184 DisplayLayout display_layout(DisplayLayout::BOTTOM, 50); | 185 DisplayLayout display_layout(DisplayLayout::BOTTOM, 50); |
| 185 display_manager->SetLayoutForCurrentDisplays(display_layout); | 186 display_manager->SetLayoutForCurrentDisplays(display_layout); |
| 186 EXPECT_EQ("50,120 150x200", | 187 EXPECT_EQ("50,120 150x200", |
| 187 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); | 188 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
| 188 | 189 |
| 189 display_manager->SetDisplayRotation(display2_id, | 190 display_manager->SetDisplayRotation(display2_id, gfx::Display::ROTATE_270, |
| 190 gfx::Display::ROTATE_270); | 191 gfx::Display::ROTATION_SOURCE_ACTIVE); |
| 191 // Move the cursor to the center of the second root window. | 192 // Move the cursor to the center of the second root window. |
| 192 generator2.MoveMouseToInHost(151, 199); | 193 generator2.MoveMouseToInHost(151, 199); |
| 193 | 194 |
| 194 magnifier->SetEnabled(true); | 195 magnifier->SetEnabled(true); |
| 195 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); | 196 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); |
| 196 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); | 197 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); |
| 197 EXPECT_EQ("50,120 200x150", | 198 EXPECT_EQ("50,120 200x150", |
| 198 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); | 199 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
| 199 generator2.MoveMouseToInHost(172, 219); | 200 generator2.MoveMouseToInHost(172, 219); |
| 200 EXPECT_EQ("95,80", event_handler.GetLocationAndReset()); | 201 EXPECT_EQ("95,80", event_handler.GetLocationAndReset()); |
| 201 EXPECT_EQ("145,200", | 202 EXPECT_EQ("145,200", |
| 202 aura::Env::GetInstance()->last_mouse_location().ToString()); | 203 aura::Env::GetInstance()->last_mouse_location().ToString()); |
| 203 EXPECT_EQ(gfx::Display::ROTATE_90, GetStoredRotation(display1.id())); | 204 EXPECT_EQ(gfx::Display::ROTATE_90, GetStoredRotation(display1.id())); |
| 204 EXPECT_EQ(gfx::Display::ROTATE_270, GetStoredRotation(display2_id)); | 205 EXPECT_EQ(gfx::Display::ROTATE_270, GetStoredRotation(display2_id)); |
| 205 magnifier->SetEnabled(false); | 206 magnifier->SetEnabled(false); |
| 206 | 207 |
| 207 display_manager->SetDisplayRotation(display1.id(), | 208 display_manager->SetDisplayRotation(display1.id(), gfx::Display::ROTATE_180, |
| 208 gfx::Display::ROTATE_180); | 209 gfx::Display::ROTATION_SOURCE_ACTIVE); |
| 209 // Move the cursor to the center of the first root window. | 210 // Move the cursor to the center of the first root window. |
| 210 generator1.MoveMouseToInHost(59, 99); | 211 generator1.MoveMouseToInHost(59, 99); |
| 211 | 212 |
| 212 magnifier->SetEnabled(true); | 213 magnifier->SetEnabled(true); |
| 213 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); | 214 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); |
| 214 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); | 215 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); |
| 215 // Dislay must share at least 100, so the x's offset becomes 20. | 216 // Dislay must share at least 100, so the x's offset becomes 20. |
| 216 EXPECT_EQ("20,200 200x150", | 217 EXPECT_EQ("20,200 200x150", |
| 217 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); | 218 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
| 218 generator1.MoveMouseToInHost(39, 59); | 219 generator1.MoveMouseToInHost(39, 59); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 // Y margin must be margin is (500 - 500/400 * 200) / 2 = 125. | 405 // Y margin must be margin is (500 - 500/400 * 200) / 2 = 125. |
| 405 EXPECT_EQ("0,125,0,125", transformer->GetHostInsets().ToString()); | 406 EXPECT_EQ("0,125,0,125", transformer->GetHostInsets().ToString()); |
| 406 | 407 |
| 407 UpdateDisplay("200x400,500x500"); | 408 UpdateDisplay("200x400,500x500"); |
| 408 // The aspect ratio is flipped, so X margin is now 125. | 409 // The aspect ratio is flipped, so X margin is now 125. |
| 409 transformer = test_api.CreateCurrentRootWindowTransformer(); | 410 transformer = test_api.CreateCurrentRootWindowTransformer(); |
| 410 EXPECT_EQ("125,0,125,0", transformer->GetHostInsets().ToString()); | 411 EXPECT_EQ("125,0,125,0", transformer->GetHostInsets().ToString()); |
| 411 } | 412 } |
| 412 | 413 |
| 413 } // namespace ash | 414 } // namespace ash |
| OLD | NEW |