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

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

Issue 143153004: [Reland] Fix crash when accidentally touching the screen during a multi window resize (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/views/tabs/tab_strip.cc ('k') | ui/views/widget/widget.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) 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 "ui/views/widget/native_widget_aura.h" 5 #include "ui/views/widget/native_widget_aura.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release); 265 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release);
266 EXPECT_TRUE(view->got_gesture_event()); 266 EXPECT_TRUE(view->got_gesture_event());
267 EXPECT_FALSE(child->got_gesture_event()); 267 EXPECT_FALSE(child->got_gesture_event());
268 view->clear_got_gesture_event(); 268 view->clear_got_gesture_event();
269 269
270 // Work around for bug in NativeWidgetAura. 270 // Work around for bug in NativeWidgetAura.
271 // TODO: fix bug and remove this. 271 // TODO: fix bug and remove this.
272 widget->Close(); 272 widget->Close();
273 } 273 }
274 274
275 TEST_F(NativeWidgetAuraTest, ReleaseCaptureOnTouchRelease) {
276 GestureTrackingView* view = new GestureTrackingView();
277 scoped_ptr<TestWidget> widget(new TestWidget());
278 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW_FRAMELESS);
279 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
280 params.context = root_window();
281 params.bounds = gfx::Rect(0, 0, 100, 200);
282 widget->Init(params);
283 widget->SetContentsView(view);
284 widget->Show();
285
286 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(41, 51), 1,
287 base::TimeDelta());
288 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press);
289 EXPECT_TRUE(view->got_gesture_event());
290 view->clear_got_gesture_event();
291 // Set the capture.
292 widget->SetCapture(view);
293 EXPECT_TRUE(widget->HasCapture());
294
295 // Generate a release, this should trigger releasing capture.
296 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(41, 51), 1,
297 base::TimeDelta());
298 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release);
299 EXPECT_TRUE(view->got_gesture_event());
300 view->clear_got_gesture_event();
301 EXPECT_FALSE(widget->HasCapture());
302
303 // Work around for bug in NativeWidgetAura.
304 // TODO: fix bug and remove this.
305 widget->Close();
306 }
307
308 // Verifies views with layers are targeted for events properly. 275 // Verifies views with layers are targeted for events properly.
309 TEST_F(NativeWidgetAuraTest, PreferViewLayersToChildWindows) { 276 TEST_F(NativeWidgetAuraTest, PreferViewLayersToChildWindows) {
310 // Create two widgets: |parent| and |child|. |child| is a child of |parent|. 277 // Create two widgets: |parent| and |child|. |child| is a child of |parent|.
311 views::View* parent_root = new views::View; 278 views::View* parent_root = new views::View;
312 scoped_ptr<Widget> parent(new Widget()); 279 scoped_ptr<Widget> parent(new Widget());
313 Widget::InitParams parent_params(Widget::InitParams::TYPE_WINDOW_FRAMELESS); 280 Widget::InitParams parent_params(Widget::InitParams::TYPE_WINDOW_FRAMELESS);
314 parent_params.ownership = 281 parent_params.ownership =
315 views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 282 views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
316 parent_params.context = root_window(); 283 parent_params.context = root_window();
317 parent->Init(parent_params); 284 parent->Init(parent_params);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 scoped_ptr<Widget> widget(new Widget()); 362 scoped_ptr<Widget> widget(new Widget());
396 NativeWidgetAura* window = Init(parent.get(), widget.get()); 363 NativeWidgetAura* window = Init(parent.get(), widget.get());
397 window->Show(); 364 window->Show();
398 window->Close(); 365 window->Close();
399 base::MessageLoop::current()->RunUntilIdle(); 366 base::MessageLoop::current()->RunUntilIdle();
400 widget->GetNativeTheme(); // Shouldn't crash. 367 widget->GetNativeTheme(); // Shouldn't crash.
401 } 368 }
402 369
403 } // namespace 370 } // namespace
404 } // namespace views 371 } // namespace views
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/tabs/tab_strip.cc ('k') | ui/views/widget/widget.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698