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

Side by Side Diff: ui/views/corewm/tooltip_controller_unittest.cc

Issue 686513004: Creating default implementation for aura::client::ScreenPositionClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 1 -> 1.0f Created 6 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
OLDNEW
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/corewm/tooltip_controller.h" 5 #include "ui/views/corewm/tooltip_controller.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "ui/aura/client/cursor_client.h" 8 #include "ui/aura/client/cursor_client.h"
9 #include "ui/aura/client/screen_position_client.h" 9 #include "ui/aura/client/screen_position_client.h"
10 #include "ui/aura/env.h" 10 #include "ui/aura/env.h"
11 #include "ui/aura/test/aura_test_base.h" 11 #include "ui/aura/test/aura_test_base.h"
12 #include "ui/aura/test/test_screen.h" 12 #include "ui/aura/test/test_screen.h"
13 #include "ui/aura/test/test_window_delegate.h" 13 #include "ui/aura/test/test_window_delegate.h"
14 #include "ui/aura/window.h" 14 #include "ui/aura/window.h"
15 #include "ui/aura/window_event_dispatcher.h" 15 #include "ui/aura/window_event_dispatcher.h"
16 #include "ui/events/test/event_generator.h" 16 #include "ui/events/test/event_generator.h"
17 #include "ui/gfx/font.h" 17 #include "ui/gfx/font.h"
18 #include "ui/gfx/point.h" 18 #include "ui/gfx/point.h"
19 #include "ui/gfx/screen.h" 19 #include "ui/gfx/screen.h"
20 #include "ui/gfx/screen_type_delegate.h" 20 #include "ui/gfx/screen_type_delegate.h"
21 #include "ui/gfx/text_elider.h" 21 #include "ui/gfx/text_elider.h"
22 #include "ui/views/corewm/tooltip_aura.h" 22 #include "ui/views/corewm/tooltip_aura.h"
23 #include "ui/views/corewm/tooltip_controller_test_helper.h" 23 #include "ui/views/corewm/tooltip_controller_test_helper.h"
24 #include "ui/views/test/desktop_test_views_delegate.h" 24 #include "ui/views/test/desktop_test_views_delegate.h"
25 #include "ui/views/test/test_views_delegate.h" 25 #include "ui/views/test/test_views_delegate.h"
26 #include "ui/views/view.h" 26 #include "ui/views/view.h"
27 #include "ui/views/widget/tooltip_manager.h" 27 #include "ui/views/widget/tooltip_manager.h"
28 #include "ui/views/widget/widget.h" 28 #include "ui/views/widget/widget.h"
29 #include "ui/wm/core/default_activation_client.h" 29 #include "ui/wm/core/default_activation_client.h"
30 #include "ui/wm/core/default_screen_position_client.h"
30 #include "ui/wm/core/wm_state.h" 31 #include "ui/wm/core/wm_state.h"
31 #include "ui/wm/public/tooltip_client.h" 32 #include "ui/wm/public/tooltip_client.h"
32 #include "ui/wm/public/window_types.h" 33 #include "ui/wm/public/window_types.h"
33 34
34 #if defined(OS_WIN) 35 #if defined(OS_WIN)
35 #include "ui/base/win/scoped_ole_initializer.h" 36 #include "ui/base/win/scoped_ole_initializer.h"
36 #endif 37 #endif
37 38
38 #if !defined(OS_CHROMEOS) 39 #if !defined(OS_CHROMEOS)
39 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" 40 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 // Returns the index of |window| in its parent's children. 405 // Returns the index of |window| in its parent's children.
405 int IndexInParent(const aura::Window* window) { 406 int IndexInParent(const aura::Window* window) {
406 aura::Window::Windows::const_iterator i = 407 aura::Window::Windows::const_iterator i =
407 std::find(window->parent()->children().begin(), 408 std::find(window->parent()->children().begin(),
408 window->parent()->children().end(), 409 window->parent()->children().end(),
409 window); 410 window);
410 return i == window->parent()->children().end() ? -1 : 411 return i == window->parent()->children().end() ? -1 :
411 static_cast<int>(i - window->parent()->children().begin()); 412 static_cast<int>(i - window->parent()->children().begin());
412 } 413 }
413 414
414 class TestScreenPositionClient : public aura::client::ScreenPositionClient {
415 public:
416 TestScreenPositionClient() {}
417 ~TestScreenPositionClient() override {}
418
419 // ScreenPositionClient overrides:
420 void ConvertPointToScreen(const aura::Window* window,
421 gfx::Point* point) override {}
422 void ConvertPointFromScreen(const aura::Window* window,
423 gfx::Point* point) override {}
424 void ConvertHostPointToScreen(aura::Window* root_gwindow,
425 gfx::Point* point) override {
426 NOTREACHED();
427 }
428 void SetBounds(aura::Window* window,
429 const gfx::Rect& bounds,
430 const gfx::Display& display) override {
431 window->SetBounds(bounds);
432 }
433
434 private:
435 DISALLOW_COPY_AND_ASSIGN(TestScreenPositionClient);
436 };
437
438 } // namespace 415 } // namespace
439 416
440 class TooltipControllerCaptureTest : public TooltipControllerTest { 417 class TooltipControllerCaptureTest : public TooltipControllerTest {
441 public: 418 public:
442 TooltipControllerCaptureTest() {} 419 TooltipControllerCaptureTest() {}
443 ~TooltipControllerCaptureTest() override {} 420 ~TooltipControllerCaptureTest() override {}
444 421
445 void SetUp() override { 422 void SetUp() override {
446 TooltipControllerTest::SetUp(); 423 TooltipControllerTest::SetUp();
447 aura::client::SetScreenPositionClient(GetRootWindow(), 424 aura::client::SetScreenPositionClient(GetRootWindow(),
448 &screen_position_client_); 425 &screen_position_client_);
449 #if !defined(OS_CHROMEOS) 426 #if !defined(OS_CHROMEOS)
450 desktop_screen_.reset(CreateDesktopScreen()); 427 desktop_screen_.reset(CreateDesktopScreen());
451 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, 428 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE,
452 desktop_screen_.get()); 429 desktop_screen_.get());
453 #endif 430 #endif
454 } 431 }
455 432
456 void TearDown() override { 433 void TearDown() override {
457 #if !defined(OS_CHROMEOS) 434 #if !defined(OS_CHROMEOS)
458 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen()); 435 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen());
459 desktop_screen_.reset(); 436 desktop_screen_.reset();
460 #endif 437 #endif
461 aura::client::SetScreenPositionClient(GetRootWindow(), NULL); 438 aura::client::SetScreenPositionClient(GetRootWindow(), NULL);
462 TooltipControllerTest::TearDown(); 439 TooltipControllerTest::TearDown();
463 } 440 }
464 441
465 private: 442 private:
466 TestScreenPositionClient screen_position_client_; 443 wm::DefaultScreenPositionClient screen_position_client_;
467 scoped_ptr<gfx::Screen> desktop_screen_; 444 scoped_ptr<gfx::Screen> desktop_screen_;
468 445
469 DISALLOW_COPY_AND_ASSIGN(TooltipControllerCaptureTest); 446 DISALLOW_COPY_AND_ASSIGN(TooltipControllerCaptureTest);
470 }; 447 };
471 448
472 // Verifies when capture is released the TooltipController resets state. 449 // Verifies when capture is released the TooltipController resets state.
473 // Flaky on all builders. http://crbug.com/388268 450 // Flaky on all builders. http://crbug.com/388268
474 TEST_F(TooltipControllerCaptureTest, DISABLED_CloseOnCaptureLost) { 451 TEST_F(TooltipControllerCaptureTest, DISABLED_CloseOnCaptureLost) {
475 view_->GetWidget()->SetCapture(view_); 452 view_->GetWidget()->SetCapture(view_);
476 RunAllPendingInMessageLoop(); 453 RunAllPendingInMessageLoop();
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 helper_->FireTooltipTimer(); 792 helper_->FireTooltipTimer();
816 tooltip_bounds1 = test_tooltip_->location(); 793 tooltip_bounds1 = test_tooltip_->location();
817 794
818 EXPECT_NE(tooltip_bounds1_1, tooltip_bounds1); 795 EXPECT_NE(tooltip_bounds1_1, tooltip_bounds1);
819 EXPECT_EQ(reference_string, helper_->GetTooltipText()); 796 EXPECT_EQ(reference_string, helper_->GetTooltipText());
820 } 797 }
821 798
822 } // namespace test 799 } // namespace test
823 } // namespace corewm 800 } // namespace corewm
824 } // namespace views 801 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698