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

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

Issue 37733003: Make GetRootWindow() return a Window instead of a RootWindow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 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 | « ui/views/corewm/tooltip_controller.cc ('k') | ui/views/drag_utils.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) 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/tooltip_client.h" 9 #include "ui/aura/client/tooltip_client.h"
10 #include "ui/aura/client/window_types.h" 10 #include "ui/aura/client/window_types.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 helper_.reset(); 94 helper_.reset();
95 widget_.reset(); 95 widget_.reset();
96 aura::test::AuraTestBase::TearDown(); 96 aura::test::AuraTestBase::TearDown();
97 } 97 }
98 98
99 protected: 99 protected:
100 aura::Window* GetWindow() { 100 aura::Window* GetWindow() {
101 return widget_->GetNativeWindow(); 101 return widget_->GetNativeWindow();
102 } 102 }
103 103
104 aura::RootWindow* GetRootWindow() { 104 aura::Window* GetRootWindow() {
105 return GetWindow()->GetRootWindow(); 105 return GetWindow()->GetRootWindow();
106 } 106 }
107 107
108 TooltipTestView* PrepareSecondView() { 108 TooltipTestView* PrepareSecondView() {
109 TooltipTestView* view2 = new TooltipTestView; 109 TooltipTestView* view2 = new TooltipTestView;
110 widget_->GetContentsView()->AddChildView(view2); 110 widget_->GetContentsView()->AddChildView(view2);
111 view_->SetBounds(0, 0, 100, 100); 111 view_->SetBounds(0, 0, 100, 100);
112 view2->SetBounds(100, 0, 100, 100); 112 view2->SetBounds(100, 0, 100, 100);
113 return view2; 113 return view2;
114 } 114 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 EXPECT_EQ(GetWindow(), helper_->GetTooltipWindow()); 152 EXPECT_EQ(GetWindow(), helper_->GetTooltipWindow());
153 } 153 }
154 154
155 TEST_F(TooltipControllerTest, TooltipsInMultipleViews) { 155 TEST_F(TooltipControllerTest, TooltipsInMultipleViews) {
156 view_->set_tooltip_text(ASCIIToUTF16("Tooltip Text")); 156 view_->set_tooltip_text(ASCIIToUTF16("Tooltip Text"));
157 EXPECT_EQ(string16(), helper_->GetTooltipText()); 157 EXPECT_EQ(string16(), helper_->GetTooltipText());
158 EXPECT_EQ(NULL, helper_->GetTooltipWindow()); 158 EXPECT_EQ(NULL, helper_->GetTooltipWindow());
159 159
160 PrepareSecondView(); 160 PrepareSecondView();
161 aura::Window* window = GetWindow(); 161 aura::Window* window = GetWindow();
162 aura::RootWindow* root_window = GetRootWindow(); 162 aura::Window* root_window = GetRootWindow();
163 163
164 // Fire tooltip timer so tooltip becomes visible. 164 // Fire tooltip timer so tooltip becomes visible.
165 generator_->MoveMouseRelativeTo(window, view_->bounds().CenterPoint()); 165 generator_->MoveMouseRelativeTo(window, view_->bounds().CenterPoint());
166 helper_->FireTooltipTimer(); 166 helper_->FireTooltipTimer();
167 EXPECT_TRUE(helper_->IsTooltipVisible()); 167 EXPECT_TRUE(helper_->IsTooltipVisible());
168 for (int i = 0; i < 49; ++i) { 168 for (int i = 0; i < 49; ++i) {
169 generator_->MoveMouseBy(1, 0); 169 generator_->MoveMouseBy(1, 0);
170 EXPECT_TRUE(helper_->IsTooltipVisible()); 170 EXPECT_TRUE(helper_->IsTooltipVisible());
171 EXPECT_EQ(window, root_window->GetEventHandlerForPoint( 171 EXPECT_EQ(window, root_window->GetEventHandlerForPoint(
172 generator_->current_location())); 172 generator_->current_location()));
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 // This test creates two top level windows and verifies that the tooltip 349 // This test creates two top level windows and verifies that the tooltip
350 // displays correctly when mouse moves are dispatched to these windows. 350 // displays correctly when mouse moves are dispatched to these windows.
351 // Additionally it also verifies that the tooltip is reparented to the new 351 // Additionally it also verifies that the tooltip is reparented to the new
352 // window when mouse moves are dispatched to it. 352 // window when mouse moves are dispatched to it.
353 TEST_F(TooltipControllerTest, TooltipsInMultipleRootWindows) { 353 TEST_F(TooltipControllerTest, TooltipsInMultipleRootWindows) {
354 view_->set_tooltip_text(ASCIIToUTF16("Tooltip Text For RootWindow1")); 354 view_->set_tooltip_text(ASCIIToUTF16("Tooltip Text For RootWindow1"));
355 EXPECT_EQ(string16(), helper_->GetTooltipText()); 355 EXPECT_EQ(string16(), helper_->GetTooltipText());
356 EXPECT_EQ(NULL, helper_->GetTooltipWindow()); 356 EXPECT_EQ(NULL, helper_->GetTooltipWindow());
357 357
358 aura::Window* window = GetWindow(); 358 aura::Window* window = GetWindow();
359 aura::RootWindow* root_window = GetRootWindow(); 359 aura::Window* root_window = GetRootWindow();
360 360
361 // Fire tooltip timer so tooltip becomes visible. 361 // Fire tooltip timer so tooltip becomes visible.
362 generator_->MoveMouseRelativeTo(window, view_->bounds().CenterPoint()); 362 generator_->MoveMouseRelativeTo(window, view_->bounds().CenterPoint());
363 helper_->FireTooltipTimer(); 363 helper_->FireTooltipTimer();
364 EXPECT_TRUE(helper_->IsTooltipVisible()); 364 EXPECT_TRUE(helper_->IsTooltipVisible());
365 for (int i = 0; i < 49; ++i) { 365 for (int i = 0; i < 49; ++i) {
366 generator_->MoveMouseBy(1, 0); 366 generator_->MoveMouseBy(1, 0);
367 EXPECT_TRUE(helper_->IsTooltipVisible()); 367 EXPECT_TRUE(helper_->IsTooltipVisible());
368 EXPECT_EQ(window, root_window->GetEventHandlerForPoint( 368 EXPECT_EQ(window, root_window->GetEventHandlerForPoint(
369 generator_->current_location())); 369 generator_->current_location()));
370 string16 expected_tooltip = 370 string16 expected_tooltip =
371 ASCIIToUTF16("Tooltip Text For RootWindow1"); 371 ASCIIToUTF16("Tooltip Text For RootWindow1");
372 EXPECT_EQ(expected_tooltip, aura::client::GetTooltipText(window)); 372 EXPECT_EQ(expected_tooltip, aura::client::GetTooltipText(window));
373 EXPECT_EQ(expected_tooltip, helper_->GetTooltipText()); 373 EXPECT_EQ(expected_tooltip, helper_->GetTooltipText());
374 EXPECT_EQ(window, helper_->GetTooltipWindow()); 374 EXPECT_EQ(window, helper_->GetTooltipWindow());
375 } 375 }
376 376
377 views::Widget* widget2 = CreateWidget(NULL); 377 views::Widget* widget2 = CreateWidget(NULL);
378 widget2->SetContentsView(new View); 378 widget2->SetContentsView(new View);
379 TooltipTestView* view2 = new TooltipTestView; 379 TooltipTestView* view2 = new TooltipTestView;
380 widget2->GetContentsView()->AddChildView(view2); 380 widget2->GetContentsView()->AddChildView(view2);
381 view2->SetBoundsRect(widget2->GetContentsView()->GetLocalBounds()); 381 view2->SetBoundsRect(widget2->GetContentsView()->GetLocalBounds());
382 helper_.reset(new TooltipControllerTestHelper( 382 helper_.reset(new TooltipControllerTestHelper(
383 GetController(widget2))); 383 GetController(widget2)));
384 generator_.reset(new aura::test::EventGenerator( 384 generator_.reset(new aura::test::EventGenerator(
385 widget2->GetNativeWindow()->GetRootWindow())); 385 widget2->GetNativeWindow()->GetRootWindow()));
386 view2->set_tooltip_text(ASCIIToUTF16("Tooltip Text For RootWindow2")); 386 view2->set_tooltip_text(ASCIIToUTF16("Tooltip Text For RootWindow2"));
387 387
388 aura::Window* window2 = widget2->GetNativeWindow(); 388 aura::Window* window2 = widget2->GetNativeWindow();
389 aura::RootWindow* root_window2 = 389 aura::Window* root_window2 =
390 widget2->GetNativeWindow()->GetRootWindow(); 390 widget2->GetNativeWindow()->GetRootWindow();
391 // Fire tooltip timer so tooltip becomes visible. 391 // Fire tooltip timer so tooltip becomes visible.
392 generator_->MoveMouseRelativeTo(window2, view2->bounds().CenterPoint()); 392 generator_->MoveMouseRelativeTo(window2, view2->bounds().CenterPoint());
393 helper_->FireTooltipTimer(); 393 helper_->FireTooltipTimer();
394 394
395 EXPECT_NE(root_window, root_window2); 395 EXPECT_NE(root_window, root_window2);
396 EXPECT_NE(window, window2); 396 EXPECT_NE(window, window2);
397 397
398 for (int i = 0; i < 49; ++i) { 398 for (int i = 0; i < 49; ++i) {
399 generator_->MoveMouseBy(1, 0); 399 generator_->MoveMouseBy(1, 0);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 EXPECT_EQ( 456 EXPECT_EQ(
457 widget_->GetNativeWindow()->GetRootWindow()->children().back()->type(), 457 widget_->GetNativeWindow()->GetRootWindow()->children().back()->type(),
458 aura::client::WINDOW_TYPE_TOOLTIP); 458 aura::client::WINDOW_TYPE_TOOLTIP);
459 } 459 }
460 460
461 #endif 461 #endif
462 462
463 } // namespace test 463 } // namespace test
464 } // namespace corewm 464 } // namespace corewm
465 } // namespace views 465 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/corewm/tooltip_controller.cc ('k') | ui/views/drag_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698