| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "ui/views/widget/desktop_aura/desktop_screen_x11.h" | 5 #include "ui/views/widget/desktop_aura/desktop_screen_x11.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "services/ui/public/interfaces/window_manager_constants.mojom.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include "ui/aura/client/aura_constants.h" | 14 #include "ui/aura/client/aura_constants.h" |
| 14 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
| 15 #include "ui/aura/window_event_dispatcher.h" | 16 #include "ui/aura/window_event_dispatcher.h" |
| 16 #include "ui/base/hit_test.h" | 17 #include "ui/base/hit_test.h" |
| 17 #include "ui/base/x/x11_util.h" | 18 #include "ui/base/x/x11_util.h" |
| 18 #include "ui/display/display_observer.h" | 19 #include "ui/display/display_observer.h" |
| 19 #include "ui/events/test/event_generator.h" | 20 #include "ui/events/test/event_generator.h" |
| 20 #include "ui/gfx/font_render_params.h" | 21 #include "ui/gfx/font_render_params.h" |
| 21 #include "ui/gfx/x/x11_types.h" | 22 #include "ui/gfx/x/x11_types.h" |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 if (!ui::WmSupportsHint(ui::GetAtom("_NET_WM_STATE_MAXIMIZED_VERT"))) | 307 if (!ui::WmSupportsHint(ui::GetAtom("_NET_WM_STATE_MAXIMIZED_VERT"))) |
| 307 return; | 308 return; |
| 308 | 309 |
| 309 Widget* widget = BuildTopLevelDesktopWidget(gfx::Rect(0, 0, 100, 100), true); | 310 Widget* widget = BuildTopLevelDesktopWidget(gfx::Rect(0, 0, 100, 100), true); |
| 310 widget->Show(); | 311 widget->Show(); |
| 311 TestDesktopNativeWidgetAura* native_widget = | 312 TestDesktopNativeWidgetAura* native_widget = |
| 312 static_cast<TestDesktopNativeWidgetAura*>(widget->native_widget()); | 313 static_cast<TestDesktopNativeWidgetAura*>(widget->native_widget()); |
| 313 native_widget->set_window_component(HTCAPTION); | 314 native_widget->set_window_component(HTCAPTION); |
| 314 | 315 |
| 315 aura::Window* window = widget->GetNativeWindow(); | 316 aura::Window* window = widget->GetNativeWindow(); |
| 316 window->SetProperty(aura::client::kCanMaximizeKey, true); | 317 window->SetProperty(aura::client::kResizeBehaviorKey, |
| 318 ui::mojom::kResizeBehaviorCanMaximize); |
| 317 | 319 |
| 318 // Cast to superclass as DesktopWindowTreeHostX11 hide IsMaximized | 320 // Cast to superclass as DesktopWindowTreeHostX11 hide IsMaximized |
| 319 DesktopWindowTreeHost* rwh = | 321 DesktopWindowTreeHost* rwh = |
| 320 DesktopWindowTreeHostX11::GetHostForXID(window->GetHost()-> | 322 DesktopWindowTreeHostX11::GetHostForXID(window->GetHost()-> |
| 321 GetAcceleratedWidget()); | 323 GetAcceleratedWidget()); |
| 322 | 324 |
| 323 ui::test::EventGenerator generator(window); | 325 ui::test::EventGenerator generator(window); |
| 324 generator.DoubleClickLeftButton(); | 326 generator.DoubleClickLeftButton(); |
| 325 RunPendingMessages(); | 327 RunPendingMessages(); |
| 326 EXPECT_TRUE(rwh->IsMaximized()); | 328 EXPECT_TRUE(rwh->IsMaximized()); |
| 327 | 329 |
| 328 widget->CloseNow(); | 330 widget->CloseNow(); |
| 329 } | 331 } |
| 330 | 332 |
| 331 // Tests that the window does not maximize in response to a double click event, | 333 // Tests that the window does not maximize in response to a double click event, |
| 332 // if the first click was to a different target component than that of the | 334 // if the first click was to a different target component than that of the |
| 333 // second click. | 335 // second click. |
| 334 TEST_F(DesktopScreenX11Test, DoubleClickTwoDifferentTargetsDoesntMaximizes) { | 336 TEST_F(DesktopScreenX11Test, DoubleClickTwoDifferentTargetsDoesntMaximizes) { |
| 335 Widget* widget = BuildTopLevelDesktopWidget(gfx::Rect(0, 0, 100, 100), true); | 337 Widget* widget = BuildTopLevelDesktopWidget(gfx::Rect(0, 0, 100, 100), true); |
| 336 widget->Show(); | 338 widget->Show(); |
| 337 TestDesktopNativeWidgetAura* native_widget = | 339 TestDesktopNativeWidgetAura* native_widget = |
| 338 static_cast<TestDesktopNativeWidgetAura*>(widget->native_widget()); | 340 static_cast<TestDesktopNativeWidgetAura*>(widget->native_widget()); |
| 339 | 341 |
| 340 aura::Window* window = widget->GetNativeWindow(); | 342 aura::Window* window = widget->GetNativeWindow(); |
| 341 window->SetProperty(aura::client::kCanMaximizeKey, true); | 343 window->SetProperty(aura::client::kResizeBehaviorKey, |
| 344 ui::mojom::kResizeBehaviorCanMaximize); |
| 342 | 345 |
| 343 // Cast to superclass as DesktopWindowTreeHostX11 hide IsMaximized | 346 // Cast to superclass as DesktopWindowTreeHostX11 hide IsMaximized |
| 344 DesktopWindowTreeHost* rwh = | 347 DesktopWindowTreeHost* rwh = |
| 345 DesktopWindowTreeHostX11::GetHostForXID(window->GetHost()-> | 348 DesktopWindowTreeHostX11::GetHostForXID(window->GetHost()-> |
| 346 GetAcceleratedWidget()); | 349 GetAcceleratedWidget()); |
| 347 | 350 |
| 348 ui::test::EventGenerator generator(window); | 351 ui::test::EventGenerator generator(window); |
| 349 native_widget->set_window_component(HTCLIENT); | 352 native_widget->set_window_component(HTCLIENT); |
| 350 generator.ClickLeftButton(); | 353 generator.ClickLeftButton(); |
| 351 native_widget->set_window_component(HTCAPTION); | 354 native_widget->set_window_component(HTCAPTION); |
| 352 generator.set_flags(ui::EF_IS_DOUBLE_CLICK); | 355 generator.set_flags(ui::EF_IS_DOUBLE_CLICK); |
| 353 generator.ClickLeftButton(); | 356 generator.ClickLeftButton(); |
| 354 generator.set_flags(ui::EF_NONE); | 357 generator.set_flags(ui::EF_NONE); |
| 355 RunPendingMessages(); | 358 RunPendingMessages(); |
| 356 EXPECT_FALSE(rwh->IsMaximized()); | 359 EXPECT_FALSE(rwh->IsMaximized()); |
| 357 | 360 |
| 358 widget->CloseNow(); | 361 widget->CloseNow(); |
| 359 } | 362 } |
| 360 | 363 |
| 361 // Tests that the window does not maximize in response to a double click event, | 364 // Tests that the window does not maximize in response to a double click event, |
| 362 // if the double click was interrupted by a right click. | 365 // if the double click was interrupted by a right click. |
| 363 TEST_F(DesktopScreenX11Test, RightClickDuringDoubleClickDoesntMaximize) { | 366 TEST_F(DesktopScreenX11Test, RightClickDuringDoubleClickDoesntMaximize) { |
| 364 Widget* widget = BuildTopLevelDesktopWidget(gfx::Rect(0, 0, 100, 100), true); | 367 Widget* widget = BuildTopLevelDesktopWidget(gfx::Rect(0, 0, 100, 100), true); |
| 365 widget->Show(); | 368 widget->Show(); |
| 366 TestDesktopNativeWidgetAura* native_widget = | 369 TestDesktopNativeWidgetAura* native_widget = |
| 367 static_cast<TestDesktopNativeWidgetAura*>(widget->native_widget()); | 370 static_cast<TestDesktopNativeWidgetAura*>(widget->native_widget()); |
| 368 | 371 |
| 369 aura::Window* window = widget->GetNativeWindow(); | 372 aura::Window* window = widget->GetNativeWindow(); |
| 370 window->SetProperty(aura::client::kCanMaximizeKey, true); | 373 window->SetProperty(aura::client::kResizeBehaviorKey, |
| 374 ui::mojom::kResizeBehaviorCanMaximize); |
| 371 | 375 |
| 372 // Cast to superclass as DesktopWindowTreeHostX11 hide IsMaximized | 376 // Cast to superclass as DesktopWindowTreeHostX11 hide IsMaximized |
| 373 DesktopWindowTreeHost* rwh = static_cast<DesktopWindowTreeHost*>( | 377 DesktopWindowTreeHost* rwh = static_cast<DesktopWindowTreeHost*>( |
| 374 DesktopWindowTreeHostX11::GetHostForXID(window->GetHost()-> | 378 DesktopWindowTreeHostX11::GetHostForXID(window->GetHost()-> |
| 375 GetAcceleratedWidget())); | 379 GetAcceleratedWidget())); |
| 376 | 380 |
| 377 ui::test::EventGenerator generator(window); | 381 ui::test::EventGenerator generator(window); |
| 378 native_widget->set_window_component(HTCLIENT); | 382 native_widget->set_window_component(HTCLIENT); |
| 379 generator.ClickLeftButton(); | 383 generator.ClickLeftButton(); |
| 380 native_widget->set_window_component(HTCAPTION); | 384 native_widget->set_window_component(HTCAPTION); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 EXPECT_EQ(2u, changed_display_.size()); | 486 EXPECT_EQ(2u, changed_display_.size()); |
| 483 | 487 |
| 484 displays[0].set_device_scale_factor(1.f); | 488 displays[0].set_device_scale_factor(1.f); |
| 485 displays[1].set_device_scale_factor(1.f); | 489 displays[1].set_device_scale_factor(1.f); |
| 486 NotifyDisplaysChanged(displays); | 490 NotifyDisplaysChanged(displays); |
| 487 EXPECT_EQ(4u, changed_display_.size()); | 491 EXPECT_EQ(4u, changed_display_.size()); |
| 488 EXPECT_EQ(1.f, gfx::GetFontRenderParamsDeviceScaleFactor()); | 492 EXPECT_EQ(1.f, gfx::GetFontRenderParamsDeviceScaleFactor()); |
| 489 } | 493 } |
| 490 | 494 |
| 491 } // namespace views | 495 } // namespace views |
| OLD | NEW |