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

Side by Side Diff: ui/views/widget/widget_unittest.cc

Issue 1260453006: ui: events: Add a class to hold common touch and stylus properties (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address build problems, add accessor and unit tests. Created 5 years, 4 months 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) 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 <algorithm> 5 #include <algorithm>
6 #include <set> 6 #include <set>
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 1688 matching lines...) Expand 10 before | Expand all | Expand 10 after
1699 View* root_view = widget->GetRootView(); 1699 View* root_view = widget->GetRootView();
1700 1700
1701 EventCountView* v1 = new EventCountView(); 1701 EventCountView* v1 = new EventCountView();
1702 v1->SetBounds(0, 0, 10, 10); 1702 v1->SetBounds(0, 0, 10, 10);
1703 root_view->AddChildView(v1); 1703 root_view->AddChildView(v1);
1704 EventCountView* v2 = new EventCountView(); 1704 EventCountView* v2 = new EventCountView();
1705 v2->SetBounds(0, 10, 10, 10); 1705 v2->SetBounds(0, 10, 10, 10);
1706 root_view->AddChildView(v2); 1706 root_view->AddChildView(v2);
1707 1707
1708 gfx::Point cursor_location(5, 5); 1708 gfx::Point cursor_location(5, 5);
1709 ui::MouseEvent move(ui::ET_MOUSE_MOVED, cursor_location, cursor_location, 1709 ui::MouseEvent move(
1710 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); 1710 ui::ET_MOUSE_MOVED, cursor_location, cursor_location,
1711 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE,
1712 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
1711 widget->OnMouseEvent(&move); 1713 widget->OnMouseEvent(&move);
1712 1714
1713 EXPECT_EQ(1, v1->GetEventCount(ui::ET_MOUSE_ENTERED)); 1715 EXPECT_EQ(1, v1->GetEventCount(ui::ET_MOUSE_ENTERED));
1714 EXPECT_EQ(0, v2->GetEventCount(ui::ET_MOUSE_ENTERED)); 1716 EXPECT_EQ(0, v2->GetEventCount(ui::ET_MOUSE_ENTERED));
1715 1717
1716 delete v1; 1718 delete v1;
1717 v2->SetBounds(0, 0, 10, 10); 1719 v2->SetBounds(0, 0, 10, 10);
1718 EXPECT_EQ(0, v2->GetEventCount(ui::ET_MOUSE_ENTERED)); 1720 EXPECT_EQ(0, v2->GetEventCount(ui::ET_MOUSE_ENTERED));
1719 1721
1720 widget->SynthesizeMouseMoveEvent(); 1722 widget->SynthesizeMouseMoveEvent();
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
2136 View* view = new RootViewTestView(); 2138 View* view = new RootViewTestView();
2137 view->SetBounds(0, 0, 300, 300); 2139 view->SetBounds(0, 0, 300, 300);
2138 internal::RootView* root_view = 2140 internal::RootView* root_view =
2139 static_cast<internal::RootView*>(widget->GetRootView()); 2141 static_cast<internal::RootView*>(widget->GetRootView());
2140 root_view->AddChildView(view); 2142 root_view->AddChildView(view);
2141 2143
2142 // Check RootView::mouse_pressed_handler_. 2144 // Check RootView::mouse_pressed_handler_.
2143 widget->Show(); 2145 widget->Show();
2144 EXPECT_EQ(NULL, GetMousePressedHandler(root_view)); 2146 EXPECT_EQ(NULL, GetMousePressedHandler(root_view));
2145 gfx::Point click_location(45, 15); 2147 gfx::Point click_location(45, 15);
2146 ui::MouseEvent press(ui::ET_MOUSE_PRESSED, click_location, click_location, 2148 ui::MouseEvent press(
2147 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 2149 ui::ET_MOUSE_PRESSED, click_location, click_location,
2148 ui::EF_LEFT_MOUSE_BUTTON); 2150 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON,
2151 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
2149 widget->OnMouseEvent(&press); 2152 widget->OnMouseEvent(&press);
2150 EXPECT_EQ(view, GetMousePressedHandler(root_view)); 2153 EXPECT_EQ(view, GetMousePressedHandler(root_view));
2151 widget->Hide(); 2154 widget->Hide();
2152 EXPECT_EQ(NULL, GetMousePressedHandler(root_view)); 2155 EXPECT_EQ(NULL, GetMousePressedHandler(root_view));
2153 2156
2154 // Check RootView::mouse_move_handler_. 2157 // Check RootView::mouse_move_handler_.
2155 widget->Show(); 2158 widget->Show();
2156 EXPECT_EQ(NULL, GetMouseMoveHandler(root_view)); 2159 EXPECT_EQ(NULL, GetMouseMoveHandler(root_view));
2157 gfx::Point move_location(45, 15); 2160 gfx::Point move_location(45, 15);
2158 ui::MouseEvent move(ui::ET_MOUSE_MOVED, move_location, move_location, 2161 ui::MouseEvent move(
2159 ui::EventTimeForNow(), 0, 0); 2162 ui::ET_MOUSE_MOVED, move_location, move_location, ui::EventTimeForNow(),
2163 0, 0, ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
2160 widget->OnMouseEvent(&move); 2164 widget->OnMouseEvent(&move);
2161 EXPECT_EQ(view, GetMouseMoveHandler(root_view)); 2165 EXPECT_EQ(view, GetMouseMoveHandler(root_view));
2162 widget->Hide(); 2166 widget->Hide();
2163 EXPECT_EQ(NULL, GetMouseMoveHandler(root_view)); 2167 EXPECT_EQ(NULL, GetMouseMoveHandler(root_view));
2164 2168
2165 // Check RootView::gesture_handler_. 2169 // Check RootView::gesture_handler_.
2166 widget->Show(); 2170 widget->Show();
2167 EXPECT_EQ(NULL, GetGestureHandler(root_view)); 2171 EXPECT_EQ(NULL, GetGestureHandler(root_view));
2168 ui::GestureEvent tap_down(15, 2172 ui::GestureEvent tap_down(15,
2169 15, 2173 15,
(...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after
3241 EXPECT_FALSE(widget->IsAlwaysOnTop()); 3245 EXPECT_FALSE(widget->IsAlwaysOnTop());
3242 widget->SetAlwaysOnTop(true); 3246 widget->SetAlwaysOnTop(true);
3243 EXPECT_TRUE(widget->IsAlwaysOnTop()); 3247 EXPECT_TRUE(widget->IsAlwaysOnTop());
3244 widget->SetAlwaysOnTop(false); 3248 widget->SetAlwaysOnTop(false);
3245 EXPECT_FALSE(widget->IsAlwaysOnTop()); 3249 EXPECT_FALSE(widget->IsAlwaysOnTop());
3246 widget->CloseNow(); 3250 widget->CloseNow();
3247 } 3251 }
3248 3252
3249 } // namespace test 3253 } // namespace test
3250 } // namespace views 3254 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698