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

Side by Side Diff: third_party/WebKit/Source/web/tests/WebPluginContainerTest.cpp

Issue 2569273002: Add constructors to WebInputEvents and setters so we can work at cleaning up these public structs. (Closed)
Patch Set: Rebase Created 3 years, 11 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 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 webView->mainFrame()->document().getElementById( 413 webView->mainFrame()->document().getElementById(
414 WebString::fromUTF8("translated-plugin")); 414 WebString::fromUTF8("translated-plugin"));
415 WebInputEvent::Modifiers modifierKey = static_cast<WebInputEvent::Modifiers>( 415 WebInputEvent::Modifiers modifierKey = static_cast<WebInputEvent::Modifiers>(
416 WebInputEvent::ControlKey | WebInputEvent::NumLockOn | 416 WebInputEvent::ControlKey | WebInputEvent::NumLockOn |
417 WebInputEvent::IsLeft); 417 WebInputEvent::IsLeft);
418 #if OS(MACOSX) 418 #if OS(MACOSX)
419 modifierKey = static_cast<WebInputEvent::Modifiers>(WebInputEvent::MetaKey | 419 modifierKey = static_cast<WebInputEvent::Modifiers>(WebInputEvent::MetaKey |
420 WebInputEvent::NumLockOn | 420 WebInputEvent::NumLockOn |
421 WebInputEvent::IsLeft); 421 WebInputEvent::IsLeft);
422 #endif 422 #endif
423 WebKeyboardEvent webKeyboardEventC; 423 WebKeyboardEvent webKeyboardEventC(WebInputEvent::RawKeyDown, modifierKey,
424 webKeyboardEventC.type = WebInputEvent::RawKeyDown; 424 WebInputEvent::TimeStampForTesting);
425 webKeyboardEventC.modifiers = modifierKey;
426 webKeyboardEventC.windowsKeyCode = 67; 425 webKeyboardEventC.windowsKeyCode = 67;
427 KeyboardEvent* keyEventC = KeyboardEvent::create(webKeyboardEventC, 0); 426 KeyboardEvent* keyEventC = KeyboardEvent::create(webKeyboardEventC, 0);
428 toWebPluginContainerImpl(pluginContainerOneElement.pluginContainer()) 427 toWebPluginContainerImpl(pluginContainerOneElement.pluginContainer())
429 ->handleEvent(keyEventC); 428 ->handleEvent(keyEventC);
430 EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText( 429 EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(
431 WebClipboard::Buffer())); 430 WebClipboard::Buffer()));
432 431
433 // Clearing |Clipboard::Buffer()|. 432 // Clearing |Clipboard::Buffer()|.
434 Platform::current()->clipboard()->writePlainText(WebString("")); 433 Platform::current()->clipboard()->writePlainText(WebString(""));
435 EXPECT_EQ(WebString(""), Platform::current()->clipboard()->readPlainText( 434 EXPECT_EQ(WebString(""), Platform::current()->clipboard()->readPlainText(
436 WebClipboard::Buffer())); 435 WebClipboard::Buffer()));
437 436
438 WebKeyboardEvent webKeyboardEventInsert; 437 WebKeyboardEvent webKeyboardEventInsert(WebInputEvent::RawKeyDown,
439 webKeyboardEventInsert.type = WebInputEvent::RawKeyDown; 438 modifierKey,
440 webKeyboardEventInsert.modifiers = modifierKey; 439 WebInputEvent::TimeStampForTesting);
441 webKeyboardEventInsert.windowsKeyCode = 45; 440 webKeyboardEventInsert.windowsKeyCode = 45;
442 KeyboardEvent* keyEventInsert = 441 KeyboardEvent* keyEventInsert =
443 KeyboardEvent::create(webKeyboardEventInsert, 0); 442 KeyboardEvent::create(webKeyboardEventInsert, 0);
444 toWebPluginContainerImpl(pluginContainerOneElement.pluginContainer()) 443 toWebPluginContainerImpl(pluginContainerOneElement.pluginContainer())
445 ->handleEvent(keyEventInsert); 444 ->handleEvent(keyEventInsert);
446 EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText( 445 EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(
447 WebClipboard::Buffer())); 446 WebClipboard::Buffer()));
448 } 447 }
449 448
450 // A class to facilitate testing that events are correctly received by plugins. 449 // A class to facilitate testing that events are correctly received by plugins.
(...skipping 30 matching lines...) Expand all
481 runPendingTasks(); 480 runPendingTasks();
482 481
483 WebElement pluginContainerOneElement = 482 WebElement pluginContainerOneElement =
484 webView->mainFrame()->document().getElementById( 483 webView->mainFrame()->document().getElementById(
485 WebString::fromUTF8("translated-plugin")); 484 WebString::fromUTF8("translated-plugin"));
486 WebPlugin* plugin = static_cast<WebPluginContainerImpl*>( 485 WebPlugin* plugin = static_cast<WebPluginContainerImpl*>(
487 pluginContainerOneElement.pluginContainer()) 486 pluginContainerOneElement.pluginContainer())
488 ->plugin(); 487 ->plugin();
489 EventTestPlugin* testPlugin = static_cast<EventTestPlugin*>(plugin); 488 EventTestPlugin* testPlugin = static_cast<EventTestPlugin*>(plugin);
490 489
491 WebGestureEvent event; 490 WebGestureEvent event(WebInputEvent::GestureLongPress,
492 event.type = WebInputEvent::GestureLongPress; 491 WebInputEvent::NoModifiers,
492 WebInputEvent::TimeStampForTesting);
493 event.sourceDevice = WebGestureDeviceTouchscreen; 493 event.sourceDevice = WebGestureDeviceTouchscreen;
494 494
495 // First, send an event that doesn't hit the plugin to verify that the 495 // First, send an event that doesn't hit the plugin to verify that the
496 // plugin doesn't receive it. 496 // plugin doesn't receive it.
497 event.x = 0; 497 event.x = 0;
498 event.y = 0; 498 event.y = 0;
499 499
500 webView->handleInputEvent(event); 500 webView->handleInputEvent(event);
501 runPendingTasks(); 501 runPendingTasks();
502 502
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 WebString::fromUTF8("translated-plugin")); 765 WebString::fromUTF8("translated-plugin"));
766 pluginContainerOneElement.pluginContainer()->setWantsWheelEvents(true); 766 pluginContainerOneElement.pluginContainer()->setWantsWheelEvents(true);
767 767
768 runPendingTasks(); 768 runPendingTasks();
769 EXPECT_TRUE( 769 EXPECT_TRUE(
770 webView->page()->frameHost().eventHandlerRegistry().hasEventHandlers( 770 webView->page()->frameHost().eventHandlerRegistry().hasEventHandlers(
771 EventHandlerRegistry::WheelEventBlocking)); 771 EventHandlerRegistry::WheelEventBlocking));
772 } 772 }
773 773
774 } // namespace blink 774 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698