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

Side by Side Diff: ui/views/controls/webview/webview_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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/controls/webview/webview.h" 5 #include "ui/views/controls/webview/webview.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "content/public/browser/web_contents.h" 8 #include "content/public/browser/web_contents.h"
9 #include "content/public/browser/web_contents_observer.h" 9 #include "content/public/browser/web_contents_observer.h"
10 #include "content/public/test/test_browser_context.h" 10 #include "content/public/test/test_browser_context.h"
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 something_to_focus->RequestFocus(); 397 something_to_focus->RequestFocus();
398 EXPECT_FALSE(web_view()->HasFocus()); 398 EXPECT_FALSE(web_view()->HasFocus());
399 EXPECT_FALSE(holder()->HasFocus()); 399 EXPECT_FALSE(holder()->HasFocus());
400 EXPECT_TRUE(something_to_focus->HasFocus()); 400 EXPECT_TRUE(something_to_focus->HasFocus());
401 401
402 // Send mouse press event to WebView outside the bounds of the holder, and 402 // Send mouse press event to WebView outside the bounds of the holder, and
403 // confirm WebView took focus. 403 // confirm WebView took focus.
404 const ui::MouseEvent click_outside_holder( 404 const ui::MouseEvent click_outside_holder(
405 ui::ET_MOUSE_PRESSED, gfx::Point(1, 1), 405 ui::ET_MOUSE_PRESSED, gfx::Point(1, 1),
406 gfx::Point(), // Immaterial. 406 gfx::Point(), // Immaterial.
407 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 0); 407 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 0,
408 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
408 EXPECT_TRUE(static_cast<views::View*>(web_view())-> 409 EXPECT_TRUE(static_cast<views::View*>(web_view())->
409 OnMousePressed(click_outside_holder)); 410 OnMousePressed(click_outside_holder));
410 EXPECT_TRUE(web_view()->HasFocus()); 411 EXPECT_TRUE(web_view()->HasFocus());
411 EXPECT_FALSE(holder()->HasFocus()); 412 EXPECT_FALSE(holder()->HasFocus());
412 EXPECT_FALSE(something_to_focus->HasFocus()); 413 EXPECT_FALSE(something_to_focus->HasFocus());
413 414
414 // Focus the other widget again. 415 // Focus the other widget again.
415 something_to_focus->RequestFocus(); 416 something_to_focus->RequestFocus();
416 EXPECT_FALSE(web_view()->HasFocus()); 417 EXPECT_FALSE(web_view()->HasFocus());
417 EXPECT_FALSE(holder()->HasFocus()); 418 EXPECT_FALSE(holder()->HasFocus());
418 EXPECT_TRUE(something_to_focus->HasFocus()); 419 EXPECT_TRUE(something_to_focus->HasFocus());
419 420
420 // Send a mouse press event within the bounds of the holder and expect no 421 // Send a mouse press event within the bounds of the holder and expect no
421 // focus change. The reason is that WebView is not supposed to handle mouse 422 // focus change. The reason is that WebView is not supposed to handle mouse
422 // events within the bounds of the holder, and it would be up to the 423 // events within the bounds of the holder, and it would be up to the
423 // WebContents native view to grab the focus instead. In this test 424 // WebContents native view to grab the focus instead. In this test
424 // environment, the WebContents native view doesn't include the implementation 425 // environment, the WebContents native view doesn't include the implementation
425 // needed to grab focus, so no focus change will occur. 426 // needed to grab focus, so no focus change will occur.
426 const ui::MouseEvent click_inside_holder( 427 const ui::MouseEvent click_inside_holder(
427 ui::ET_MOUSE_PRESSED, web_view()->bounds().CenterPoint(), 428 ui::ET_MOUSE_PRESSED, web_view()->bounds().CenterPoint(),
428 gfx::Point(), // Immaterial. 429 gfx::Point(), // Immaterial.
429 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 0); 430 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 0,
431 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
430 EXPECT_FALSE(static_cast<views::View*>(web_view())-> 432 EXPECT_FALSE(static_cast<views::View*>(web_view())->
431 OnMousePressed(click_inside_holder)); 433 OnMousePressed(click_inside_holder));
432 EXPECT_FALSE(web_view()->HasFocus()); 434 EXPECT_FALSE(web_view()->HasFocus());
433 EXPECT_FALSE(holder()->HasFocus()); 435 EXPECT_FALSE(holder()->HasFocus());
434 EXPECT_TRUE(something_to_focus->HasFocus()); 436 EXPECT_TRUE(something_to_focus->HasFocus());
435 } 437 }
436 438
437 } // namespace views 439 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698