• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
2 // reserved. Use of this source code is governed by a BSD-style license that
3 // can be found in the LICENSE file.
4 
5 #include "include/base/cef_callback.h"
6 #include "include/base/cef_logging.h"
7 #include "include/cef_parser.h"
8 #include "include/cef_v8.h"
9 #include "include/wrapper/cef_closure_task.h"
10 #include "include/wrapper/cef_stream_resource_handler.h"
11 #include "tests/ceftests/routing_test_handler.h"
12 #include "tests/gtest/include/gtest/gtest.h"
13 #include "tests/shared/browser/geometry_util.h"
14 #include "tests/shared/browser/resource_util.h"
15 
16 #if defined(OS_MAC)
17 #include <Carbon/Carbon.h>  // For character codes.
18 #include "tests/ceftests/os_rendering_unittest_mac.h"
19 #elif defined(OS_LINUX)
20 #include <X11/keysym.h>
21 #elif defined(OS_WIN)
22 // Required for resource_util_win, which uses this as an extern
23 HINSTANCE hInst = ::GetModuleHandle(nullptr);
24 #endif
25 
26 namespace {
27 
28 const char kTestUrl[] = "http://tests/osrtest";
29 
30 // this html should render on a 600 x 400 window with a little vertical
31 // offset with scrollbar.
32 
33 // default osr widget size
34 const int kOsrWidth = 600;
35 const int kOsrHeight = 400;
36 
37 // bounding client rects for edit box and navigate button
38 #if defined(OS_WIN)
39 const CefRect kExpandedSelectRect(462, 42, 81, 334);
40 #elif defined(OS_MAC)
41 const CefRect kExpandedSelectRect(462, 42, 75, 334);
42 #elif defined(OS_LINUX)
43 const CefRect kExpandedSelectRect(462, 42, 79, 334);
44 #else
45 #error "Unsupported platform"
46 #endif  // defined(OS_WIN)
47 
48 // word to be written into edit box
49 const char kKeyTestWord[] = "done";
50 
51 #if defined(OS_LINUX)
52 
53 // From ui/events/keycodes/keyboard_codes_posix.h
54 #define VKEY_D 0x44
55 #define VKEY_O 0x4F
56 #define VKEY_N 0x4E
57 #define VKEY_E 0x45
58 #define VKEY_ESCAPE 0x1B
59 #define VKEY_TAB 0x09
60 
61 const unsigned int kNativeKeyTestCodes[] = {XK_d, XK_o, XK_n, XK_e};
62 
63 const unsigned int kNativeKeyEscape = XK_Escape;
64 const unsigned int kNativeKeyTab = XK_Tab;
65 
66 #elif defined(OS_MAC)
67 
68 // See kKeyCodesMap in ui/events/keycodes/keyboard_code_conversion_mac.mm
69 #define VKEY_D 'd'
70 #define VKEY_O 'o'
71 #define VKEY_N 'n'
72 #define VKEY_E 'e'
73 #define VKEY_ESCAPE kEscapeCharCode
74 #define VKEY_TAB kTabCharCode
75 
76 const unsigned int kNativeKeyTestCodes[] = {kVK_ANSI_D, kVK_ANSI_O, kVK_ANSI_N,
77                                             kVK_ANSI_E};
78 
79 const unsigned int kNativeKeyEscape = kVK_Escape;
80 const unsigned int kNativeKeyTab = kVK_Tab;
81 
82 #endif
83 
84 #if defined(OS_MAC) || defined(OS_LINUX)
85 
86 const unsigned int kKeyTestCodes[] = {VKEY_D, VKEY_O, VKEY_N, VKEY_E};
87 
88 #endif
89 
90 // test type
91 enum OSRTestType {
92   // IsWindowRenderingDisabled should be true
93   OSR_TEST_IS_WINDOWLESS,
94   // focusing webview, LI00 will get red & repainted
95   OSR_TEST_FOCUS,
96   // tab key traversal should iterate the focus across HTML element and
97   // subsequently after last element CefFocusHandler::OnTakeFocus should be
98   // called to allow giving focus to the next component.
99   OSR_TEST_TAKE_FOCUS,
100   // send focus event should set focus on the webview
101   OSR_TEST_GOT_FOCUS,
102   // loading webview should trigger a full paint (L01)
103   OSR_TEST_PAINT,
104   // same as OSR_TEST_PAINT but with alpha values
105   OSR_TEST_TRANSPARENCY,
106   // moving mouse over L02, OnCursorChange will be called
107   OSR_TEST_CURSOR,
108   // moving mouse on L03, OnPaint will be called for its bounding rectangle
109   OSR_TEST_MOUSE_MOVE,
110   // right clicking an element (L04), OnBeforeContextMenu should be called
111   OSR_TEST_CLICK_RIGHT,
112   // right clicking an element (L04), context menu will query screen point
113   OSR_TEST_SCREEN_POINT,
114   // left click in text box should query repainting edit box area
115   OSR_TEST_CLICK_LEFT,
116   // Resize should trigger a full repaint with the new given size
117   OSR_TEST_RESIZE,
118   // Invalidate should trigger repaint synchronously
119   OSR_TEST_INVALIDATE,
120   // write into editbox LI08, click to navigate on LI09
121   OSR_TEST_KEY_EVENTS,
122   // mouse over LI10 will show a tooltip
123   OSR_TEST_TOOLTIP,
124   // mouse wheel will trigger a scroll event
125   OSR_TEST_SCROLLING,
126   // Right click will trigger a context menu, and on destroying the test, it
127   // should not crash
128   OSR_TEST_CONTEXT_MENU,
129   // clicking on dropdown box, PET_POPUP OnPaint is triggered
130   OSR_TEST_POPUP_PAINT,
131   // clicking on dropdown box, a popup will show up
132   OSR_TEST_POPUP_SHOW,
133   // clicking on dropdown box, OnPopupSize should be called
134   OSR_TEST_POPUP_SIZE,
135   // taking focus away from the webview, will close popup
136   OSR_TEST_POPUP_HIDE_ON_BLUR,
137   // clicking outside the popup widget will close popup
138   OSR_TEST_POPUP_HIDE_ON_CLICK,
139   // scrolling outside the popup widget will close popup
140   OSR_TEST_POPUP_HIDE_ON_SCROLL,
141   // pressing ESC will close popup
142   OSR_TEST_POPUP_HIDE_ON_ESC,
143   // scrolling inside the popup should trigger repaint for popup area
144   OSR_TEST_POPUP_SCROLL_INSIDE,
145   // clicking and moving the mouse will call StartDragging
146   OSR_TEST_DRAG_DROP_START_DRAGGING,
147   // starting dragging over the drop region will call UpdateDragCursor
148   OSR_TEST_DRAG_DROP_UPDATE_CURSOR,
149   // dropping element inside drop region will move the element
150   OSR_TEST_DRAG_DROP_DROP,
151   // IMESetComposition will update the composition range
152   OSR_TEST_IME_SET_COMPOSITION,
153   // IMECommitText inserts the specified text
154   OSR_TEST_IME_COMMIT_TEXT,
155   // IMEFinishComposition will commit the text present composition text
156   OSR_TEST_IME_FINISH_COMPOSITION,
157   // IMECancelComposition will update the composition range
158   OSR_TEST_IME_CANCEL_COMPOSITION,
159   // text selection range changed
160   OSR_TEST_TEXT_SELECTION_CHANGE,
161   // clicking on text input will call OnVirtualKeyboardRequested
162   OSR_TEST_VIRTUAL_KEYBOARD,
163   // touchStart event is triggered and contains the touch point count
164   OSR_TEST_TOUCH_START,
165   // touchMove event is triggered and contains the changed touch points
166   OSR_TEST_TOUCH_MOVE,
167   // touchEnd is triggered on completion
168   OSR_TEST_TOUCH_END,
169   // touchCancel is triggered on dismissing
170   OSR_TEST_TOUCH_CANCEL,
171   // CEF_POINTER_TYPE_PEN is mapped to pen pointer event
172   OSR_TEST_PEN,
173   // Define the range for popup tests.
174   OSR_TEST_POPUP_FIRST = OSR_TEST_POPUP_PAINT,
175   OSR_TEST_POPUP_LAST = OSR_TEST_POPUP_SCROLL_INSIDE,
176 };
177 
178 // Used in the browser process.
179 class OSRTestHandler : public RoutingTestHandler,
180                        public CefFocusHandler,
181                        public CefRenderHandler,
182                        public CefContextMenuHandler {
183  public:
OSRTestHandler(OSRTestType test_type,float scale_factor)184   OSRTestHandler(OSRTestType test_type, float scale_factor)
185       : test_type_(test_type),
186         scale_factor_(scale_factor),
187         event_count_(0),
188         event_total_(1),
189         started_(false),
190         touch_state_(CEF_TET_CANCELLED) {}
191 
192   // TestHandler methods
RunTest()193   void RunTest() override {
194     CreateOSRBrowser(kTestUrl);
195 
196     // Time out the test after a reasonable period of time.
197     SetTestTimeout();
198   }
199 
OnAfterCreated(CefRefPtr<CefBrowser> browser)200   void OnAfterCreated(CefRefPtr<CefBrowser> browser) override {
201     if (test_type_ == OSR_TEST_IS_WINDOWLESS) {
202       EXPECT_TRUE(browser->GetHost()->IsWindowRenderingDisabled());
203       DestroySucceededTestSoon();
204     }
205     RoutingTestHandler::OnAfterCreated(browser);
206   }
207 
OnLoadEnd(CefRefPtr<CefBrowser> browser,CefRefPtr<CefFrame> frame,int httpStatusCode)208   void OnLoadEnd(CefRefPtr<CefBrowser> browser,
209                  CefRefPtr<CefFrame> frame,
210                  int httpStatusCode) override {
211     if (!started())
212       return;
213 
214     switch (test_type_) {
215       case OSR_TEST_KEY_EVENTS: {
216         const std::string& expected_url =
217             std::string(kTestUrl) + "?k=" + kKeyTestWord;
218         EXPECT_STREQ(expected_url.c_str(), frame->GetURL().ToString().c_str());
219         DestroySucceededTestSoon();
220       } break;
221       case OSR_TEST_IME_COMMIT_TEXT: {
222         const std::string& expected_url =
223             std::string(kTestUrl) + "?k=osrimecommit";
224         EXPECT_STREQ(expected_url.c_str(), frame->GetURL().ToString().c_str());
225         DestroySucceededTestSoon();
226       } break;
227       case OSR_TEST_IME_FINISH_COMPOSITION: {
228         const std::string& expected_url =
229             std::string(kTestUrl) + "?k=" + kKeyTestWord;
230         EXPECT_STREQ(expected_url.c_str(), frame->GetURL().ToString().c_str());
231         DestroySucceededTestSoon();
232       } break;
233       case OSR_TEST_IME_CANCEL_COMPOSITION: {
234         const std::string& expected_url = std::string(kTestUrl) + "?k=";
235         EXPECT_STREQ(expected_url.c_str(), frame->GetURL().ToString().c_str());
236         DestroySucceededTestSoon();
237       } break;
238       default:
239         // Intentionally left blank
240         break;
241     }
242   }
243 
OnQuery(CefRefPtr<CefBrowser> browser,CefRefPtr<CefFrame> frame,int64 query_id,const CefString & request,bool persistent,CefRefPtr<Callback> callback)244   bool OnQuery(CefRefPtr<CefBrowser> browser,
245                CefRefPtr<CefFrame> frame,
246                int64 query_id,
247                const CefString& request,
248                bool persistent,
249                CefRefPtr<Callback> callback) override {
250     EXPECT_TRUE(browser.get());
251 
252     if (!started()) {
253       return handleBoundsQuery(browser, frame, query_id, request, persistent,
254                                callback);
255     }
256 
257     const std::string& messageStr = request;
258     switch (test_type_) {
259       case OSR_TEST_FOCUS:
260         EXPECT_STREQ(messageStr.c_str(), "osrfocus");
261         DestroySucceededTestSoon();
262         break;
263       case OSR_TEST_CLICK_LEFT:
264         EXPECT_STREQ(messageStr.c_str(), "osrclick0");
265         DestroySucceededTestSoon();
266         break;
267       case OSR_TEST_MOUSE_MOVE:
268         EXPECT_STREQ(messageStr.c_str(), "osrmousemove");
269         DestroySucceededTestSoon();
270         break;
271       case OSR_TEST_DRAG_DROP_DROP:
272         EXPECT_STREQ(messageStr.c_str(), "osrdrop");
273         DestroySucceededTestSoon();
274         break;
275       case OSR_TEST_TOUCH_START:
276       case OSR_TEST_TOUCH_MOVE:
277       case OSR_TEST_TOUCH_END:
278       case OSR_TEST_TOUCH_CANCEL: {
279         switch (touch_state_) {
280           case CEF_TET_CANCELLED: {
281             // The first message expected is touchstart.
282             // We expect multitouch, so touches length should be 2.
283             // Ignore intermediate touch start events.
284             if (messageStr == "osrtouchstart1")
285               break;
286             EXPECT_STREQ(messageStr.c_str(), "osrtouchstart2");
287             // Close Touch Start Tests.
288             if (test_type_ == OSR_TEST_TOUCH_START) {
289               DestroySucceededTestSoon();
290               touch_state_ = CEF_TET_RELEASED;
291             } else {
292               touch_state_ = CEF_TET_PRESSED;
293             }
294           } break;
295           case CEF_TET_PRESSED: {
296             // Touch Move include the touches that changed, should be 2.
297             EXPECT_STREQ(messageStr.c_str(), "osrtouchmove2");
298             if (test_type_ == OSR_TEST_TOUCH_MOVE) {
299               DestroySucceededTestSoon();
300               touch_state_ = CEF_TET_RELEASED;
301             } else {
302               touch_state_ = CEF_TET_MOVED;
303             }
304           } break;
305           case CEF_TET_MOVED: {
306             // There might be multiple touchmove events, ignore.
307             if (messageStr != "osrtouchmove2") {
308               if (test_type_ == OSR_TEST_TOUCH_END) {
309                 EXPECT_STREQ(messageStr.c_str(), "osrtouchend");
310                 DestroySucceededTestSoon();
311                 touch_state_ = CEF_TET_RELEASED;
312               } else if (test_type_ == OSR_TEST_TOUCH_CANCEL) {
313                 EXPECT_STREQ(messageStr.c_str(), "osrtouchcancel");
314                 DestroySucceededTestSoon();
315                 touch_state_ = CEF_TET_RELEASED;
316               }
317             }
318           } break;
319           default:
320             break;
321         }
322       } break;
323       case OSR_TEST_PEN: {
324         switch (touch_state_) {
325           case CEF_TET_CANCELLED:
326             // The first message expected is pointerdown.
327             EXPECT_STREQ(messageStr.c_str(), "osrpointerdown pen");
328             touch_state_ = CEF_TET_PRESSED;
329             break;
330           case CEF_TET_PRESSED:
331             EXPECT_STREQ(messageStr.c_str(), "osrpointermove pen");
332             touch_state_ = CEF_TET_MOVED;
333             break;
334           case CEF_TET_MOVED:
335             // There might be multiple pointermove events, ignore.
336             if (messageStr != "osrpointermove pen") {
337               EXPECT_STREQ(messageStr.c_str(), "osrpointerup pen");
338               DestroySucceededTestSoon();
339             }
340             break;
341           default:
342             break;
343         }
344       } break;
345       default:
346         // Intentionally left blank
347         break;
348     }
349     callback->Success("");
350     return true;
351   }
352 
handleBoundsQuery(CefRefPtr<CefBrowser> browser,CefRefPtr<CefFrame> frame,int64 query_id,const CefString & request,bool persistent,CefRefPtr<Callback> callback)353   bool handleBoundsQuery(CefRefPtr<CefBrowser> browser,
354                          CefRefPtr<CefFrame> frame,
355                          int64 query_id,
356                          const CefString& request,
357                          bool persistent,
358                          CefRefPtr<Callback> callback) {
359     CefRefPtr<CefValue> jsonObj = CefParseJSON(request, JSON_PARSER_RFC);
360     if (jsonObj.get()) {
361       CefRefPtr<CefDictionaryValue> dict = jsonObj->GetDictionary();
362       const std::string& type = dict->GetString("type");
363       if (type == "ElementBounds") {
364         CefRefPtr<CefListValue> elems = dict->GetList("elems");
365 
366         for (size_t i = 0; i < elems->GetSize(); i++) {
367           CefRefPtr<CefDictionaryValue> elem = elems->GetDictionary(i);
368           std::string elementId = elem->GetString("id");
369           CefRect bounds(elem->GetInt("x"), elem->GetInt("y"),
370                          elem->GetInt("width"), elem->GetInt("height"));
371           element_bounds_.insert(std::make_pair(elementId, bounds));
372         }
373         return true;
374       }
375     }
376 
377     return false;
378   }
379 
380   // CefClient methods, providing handlers
GetFocusHandler()381   CefRefPtr<CefFocusHandler> GetFocusHandler() override { return this; }
382 
GetRenderHandler()383   CefRefPtr<CefRenderHandler> GetRenderHandler() override { return this; }
384 
GetContextMenuHandler()385   CefRefPtr<CefContextMenuHandler> GetContextMenuHandler() override {
386     return this;
387   }
388 
389   // CefResourceRequestHandler methods
GetResourceHandler(CefRefPtr<CefBrowser> browser,CefRefPtr<CefFrame> frame,CefRefPtr<CefRequest> request)390   CefRefPtr<CefResourceHandler> GetResourceHandler(
391       CefRefPtr<CefBrowser> browser,
392       CefRefPtr<CefFrame> frame,
393       CefRefPtr<CefRequest> request) override {
394     std::string url = request->GetURL();
395 
396     if (url.find(kTestUrl) == 0) {
397       // Show the osr test contents
398       CefRefPtr<CefStreamReader> stream =
399           client::GetBinaryResourceReader("osr_test.html");
400       return new CefStreamResourceHandler("text/html", stream);
401     }
402 
403     return nullptr;
404   }
405 
406   // CefRenderHandler methods
GetViewRect(CefRefPtr<CefBrowser> browser,CefRect & rect)407   void GetViewRect(CefRefPtr<CefBrowser> browser, CefRect& rect) override {
408     if (test_type_ == OSR_TEST_RESIZE && started()) {
409       rect = CefRect(0, 0, kOsrWidth * 2, kOsrHeight * 2);
410       return;
411     }
412     rect = CefRect(0, 0, kOsrWidth, kOsrHeight);
413   }
414 
GetScreenPoint(CefRefPtr<CefBrowser> browser,int viewX,int viewY,int & screenX,int & screenY)415   bool GetScreenPoint(CefRefPtr<CefBrowser> browser,
416                       int viewX,
417                       int viewY,
418                       int& screenX,
419                       int& screenY) override {
420     if (test_type_ == OSR_TEST_SCREEN_POINT && started()) {
421       const CefRect& expected_rect = GetElementBounds("LI04");
422       EXPECT_EQ(viewX, MiddleX(expected_rect));
423       EXPECT_EQ(viewY, MiddleY(expected_rect));
424       DestroySucceededTestSoon();
425     } else if (test_type_ == OSR_TEST_CONTEXT_MENU && started()) {
426       screenX = 0;
427       screenY = 0;
428       return true;
429     }
430     // we don't want to see a contextual menu. stop here.
431     return false;
432   }
433 
GetScreenInfo(CefRefPtr<CefBrowser> browser,CefScreenInfo & screen_info)434   bool GetScreenInfo(CefRefPtr<CefBrowser> browser,
435                      CefScreenInfo& screen_info) override {
436     screen_info.device_scale_factor = scale_factor_;
437 
438     // The screen info rectangles are used by the renderer to create and
439     // position popups. If not overwritten in this function, the rectangle
440     // returned from GetViewRect will be used to popuplate them.
441     // The popup in the test fits without modifications in the test window, so
442     // setting the screen to the test window size does not affect its rectangle.
443     screen_info.rect = CefRect(0, 0, kOsrWidth, kOsrHeight);
444     screen_info.available_rect = screen_info.rect;
445     return true;
446   }
447 
OnPopupShow(CefRefPtr<CefBrowser> browser,bool show)448   void OnPopupShow(CefRefPtr<CefBrowser> browser, bool show) override {
449     if (show && started()) {
450       switch (test_type_) {
451         case OSR_TEST_POPUP_SHOW:
452           if (!succeeded()) {
453             EXPECT_TRUE(show);
454             DestroySucceededTestSoon();
455           }
456           break;
457         default:
458           break;
459       }
460     }
461     if (!show && started()) {
462       switch (test_type_) {
463         case OSR_TEST_POPUP_HIDE_ON_BLUR:
464         case OSR_TEST_POPUP_HIDE_ON_CLICK:
465         case OSR_TEST_POPUP_HIDE_ON_ESC:
466         case OSR_TEST_POPUP_HIDE_ON_SCROLL:
467           DestroySucceededTestSoon();
468           break;
469         default:
470           break;
471       }
472     }
473   }
474 
OnPopupSize(CefRefPtr<CefBrowser> browser,const CefRect & rect)475   void OnPopupSize(CefRefPtr<CefBrowser> browser,
476                    const CefRect& rect) override {
477     if (started()) {
478       switch (test_type_) {
479         case OSR_TEST_POPUP_SIZE:
480           EXPECT_EQ(kExpandedSelectRect.x, rect.x);
481           EXPECT_EQ(kExpandedSelectRect.y, rect.y);
482           if (ExpectComputedPopupSize()) {
483             EXPECT_EQ(kExpandedSelectRect.width, rect.width);
484             EXPECT_EQ(kExpandedSelectRect.height, rect.height);
485           } else {
486             EXPECT_GE(rect.width, kExpandedSelectRect.width);
487             EXPECT_GE(rect.height, kExpandedSelectRect.height);
488           }
489           DestroySucceededTestSoon();
490           break;
491         default:
492           break;
493       }
494     }
495   }
496 
OnPaint(CefRefPtr<CefBrowser> browser,PaintElementType type,const RectList & dirtyRects,const void * buffer,int width,int height)497   void OnPaint(CefRefPtr<CefBrowser> browser,
498                PaintElementType type,
499                const RectList& dirtyRects,
500                const void* buffer,
501                int width,
502                int height) override {
503     // bitmap must as big as GetViewRect said
504     if (test_type_ != OSR_TEST_RESIZE && type == PET_VIEW) {
505       EXPECT_EQ(GetScaledInt(kOsrWidth), width);
506       EXPECT_EQ(GetScaledInt(kOsrHeight), height);
507     } else if (type == PET_POPUP) {
508       const CefRect& expanded_select_rect = GetScaledRect(kExpandedSelectRect);
509       if (ExpectComputedPopupSize()) {
510         EXPECT_EQ(expanded_select_rect.width, width);
511         EXPECT_EQ(expanded_select_rect.height, height);
512       } else {
513         EXPECT_GT(width, kExpandedSelectRect.width);
514         EXPECT_GT(height, kExpandedSelectRect.height);
515       }
516     }
517 
518     EXPECT_TRUE(browser->GetHost()->IsWindowRenderingDisabled());
519 
520     // start test only when painting something else then background
521     if (IsBackgroundInBuffer(
522             reinterpret_cast<const uint32*>(buffer), width * height,
523             test_type_ == OSR_TEST_TRANSPARENCY ? 0x00000000 : 0xFFFFFFFF))
524       return;
525 
526     // Send events after the first full repaint
527     switch (test_type_) {
528       case OSR_TEST_PAINT:
529         if (StartTest()) {
530           // test that we have a full repaint
531           EXPECT_EQ(dirtyRects.size(), 1U);
532           EXPECT_TRUE(IsFullRepaint(dirtyRects[0], GetScaledInt(kOsrWidth),
533                                     GetScaledInt(kOsrHeight)));
534           EXPECT_EQ(0xffff7f7fU, *(reinterpret_cast<const uint32*>(buffer)));
535           DestroySucceededTestSoon();
536         }
537         break;
538       case OSR_TEST_TRANSPARENCY:
539         if (StartTest()) {
540           // test that we have a full repaint
541           EXPECT_EQ(dirtyRects.size(), 1U);
542           EXPECT_TRUE(IsFullRepaint(dirtyRects[0], GetScaledInt(kOsrWidth),
543                                     GetScaledInt(kOsrHeight)));
544           EXPECT_EQ(0x80800000U, *(reinterpret_cast<const uint32*>(buffer)));
545           DestroySucceededTestSoon();
546         }
547         break;
548       case OSR_TEST_FOCUS:
549         if (StartTest()) {
550           // body.onfocus will make LI00 red
551           browser->GetHost()->SetFocus(true);
552         }
553         break;
554       case OSR_TEST_TAKE_FOCUS:
555         if (StartTest() || started()) {
556           // Tab traversal across HTML element
557 
558 #if defined(OS_WIN)
559           SendKeyEvent(browser, VK_TAB);
560 #elif defined(OS_MAC) || defined(OS_LINUX)
561           SendKeyEvent(browser, kNativeKeyTab, VKEY_TAB);
562 #else
563 #error "Unsupported platform"
564 #endif
565         }
566         break;
567       case OSR_TEST_GOT_FOCUS:
568         if (StartTest()) {
569           browser->GetHost()->SetFocus(true);
570         }
571         break;
572       case OSR_TEST_CURSOR:
573         if (StartTest()) {
574           // make mouse leave first
575           CefMouseEvent mouse_event;
576           mouse_event.x = 0;
577           mouse_event.y = 0;
578           mouse_event.modifiers = 0;
579           browser->GetHost()->SendMouseMoveEvent(mouse_event, true);
580           // enter mouse in the LI2 element having hand cursor
581           const CefRect& expected_rect = GetElementBounds("LI02");
582           mouse_event.x = MiddleX(expected_rect);
583           mouse_event.y = MiddleY(expected_rect);
584           browser->GetHost()->SendMouseMoveEvent(mouse_event, false);
585         }
586         break;
587       case OSR_TEST_MOUSE_MOVE:
588         if (StartTest()) {
589           CefMouseEvent mouse_event;
590           const CefRect& expected_rect = GetElementBounds("LI03");
591           mouse_event.x = MiddleX(expected_rect);
592           mouse_event.y = MiddleY(expected_rect);
593           mouse_event.modifiers = 0;
594           browser->GetHost()->SendMouseMoveEvent(mouse_event, false);
595         }
596         break;
597       case OSR_TEST_CLICK_RIGHT:
598       case OSR_TEST_SCREEN_POINT:
599       case OSR_TEST_CONTEXT_MENU:
600         if (StartTest()) {
601           CefMouseEvent mouse_event;
602           const CefRect& expected_rect = GetElementBounds("LI04");
603           mouse_event.x = MiddleX(expected_rect);
604           mouse_event.y = MiddleY(expected_rect);
605           mouse_event.modifiers = 0;
606           browser->GetHost()->SendMouseClickEvent(mouse_event, MBT_RIGHT, false,
607                                                   1);
608           browser->GetHost()->SendMouseClickEvent(mouse_event, MBT_RIGHT, true,
609                                                   1);
610         }
611         break;
612       case OSR_TEST_CLICK_LEFT:
613         if (StartTest()) {
614           CefMouseEvent mouse_event;
615           const CefRect& expected_rect = GetElementBounds("LI00");
616           mouse_event.x = MiddleX(expected_rect);
617           mouse_event.y = MiddleY(expected_rect);
618 
619           mouse_event.modifiers = 0;
620           browser->GetHost()->SendMouseClickEvent(mouse_event, MBT_LEFT, false,
621                                                   1);
622           browser->GetHost()->SendMouseClickEvent(mouse_event, MBT_LEFT, true,
623                                                   1);
624         }
625         break;
626       case OSR_TEST_RESIZE:
627         if (StartTest()) {
628           browser->GetHost()->WasResized();
629         } else {
630           // There may be some partial repaints before the full repaint at the
631           // desired size.
632           const int desired_width = GetScaledInt(kOsrWidth) * 2;
633           const int desired_height = GetScaledInt(kOsrHeight) * 2;
634 
635           EXPECT_EQ(dirtyRects.size(), 1U);
636           if (width == desired_width && height == desired_height &&
637               IsFullRepaint(dirtyRects[0], width, height)) {
638             DestroySucceededTestSoon();
639           }
640         }
641         break;
642       case OSR_TEST_INVALIDATE: {
643         if (StartTest()) {
644           browser->GetHost()->Invalidate(PET_VIEW);
645         } else {
646           EXPECT_EQ(dirtyRects.size(), 1U);
647           const CefRect& expected_rect =
648               GetScaledRect(CefRect(0, 0, kOsrWidth, kOsrHeight));
649           // There may be some partial repaints before the full repaint.
650           if (dirtyRects[0] == expected_rect)
651             DestroySucceededTestSoon();
652         }
653         break;
654       }
655       case OSR_TEST_KEY_EVENTS:
656         if (StartTest()) {
657           // click inside edit box
658           CefMouseEvent mouse_event;
659           const CefRect& editbox = GetElementBounds("editbox");
660           mouse_event.x = MiddleX(editbox);
661           mouse_event.y = MiddleY(editbox);
662           mouse_event.modifiers = 0;
663           browser->GetHost()->SendMouseClickEvent(mouse_event, MBT_LEFT, false,
664                                                   1);
665           browser->GetHost()->SendMouseClickEvent(mouse_event, MBT_LEFT, true,
666                                                   1);
667 
668           // write "done" word
669           CefKeyEvent event;
670           event.is_system_key = false;
671           event.modifiers = 0;
672 
673           size_t word_length = strlen(kKeyTestWord);
674           for (size_t i = 0; i < word_length; ++i) {
675 #if defined(OS_WIN)
676             SendKeyEvent(browser, kKeyTestWord[i]);
677 #elif defined(OS_MAC) || defined(OS_LINUX)
678             SendKeyEvent(browser, kNativeKeyTestCodes[i], kKeyTestCodes[i]);
679 #else
680 #error "Unsupported platform"
681 #endif
682           }
683 
684           // click button to navigate
685           const CefRect& btnnavigate = GetElementBounds("btnnavigate");
686           mouse_event.x = MiddleX(btnnavigate);
687           mouse_event.y = MiddleY(btnnavigate);
688           browser->GetHost()->SendMouseClickEvent(mouse_event, MBT_LEFT, false,
689                                                   1);
690           browser->GetHost()->SendMouseClickEvent(mouse_event, MBT_LEFT, true,
691                                                   1);
692         }
693         break;
694       case OSR_TEST_TOOLTIP:
695         if (StartTest()) {
696           CefMouseEvent mouse_event;
697           const CefRect& expected_rect = GetElementBounds("LI10");
698           mouse_event.x = MiddleX(expected_rect);
699           mouse_event.y = MiddleY(expected_rect);
700           mouse_event.modifiers = 0;
701           browser->GetHost()->SendMouseMoveEvent(mouse_event, false);
702         }
703         break;
704       case OSR_TEST_SCROLLING: {
705         static const int deltaY = 10;
706         if (StartTest()) {
707           // scroll down once
708           CefMouseEvent mouse_event;
709           const CefRect& expected_rect = GetElementBounds("LI00");
710           mouse_event.x = MiddleX(expected_rect);
711           mouse_event.y = MiddleY(expected_rect);
712           mouse_event.modifiers = 0;
713           browser->GetHost()->SendMouseWheelEvent(mouse_event, 0, -deltaY);
714         } else {
715           EXPECT_EQ(dirtyRects.size(), 1U);
716           const CefRect& expected_rect =
717               GetScaledRect(CefRect(0, 0, kOsrWidth, kOsrHeight));
718           // There may be some partial repaints before the full repaint.
719           if (dirtyRects[0] == expected_rect)
720             DestroySucceededTestSoon();
721         }
722         break;
723       }
724       case OSR_TEST_POPUP_HIDE_ON_CLICK:
725         if (StartTest()) {
726           ExpandDropDown();
727           // Wait for the first popup paint to occur
728         } else if (type == PET_POPUP) {
729           CefMouseEvent mouse_event;
730           mouse_event.x = 1;
731           mouse_event.y = 1;
732           mouse_event.modifiers = 0;
733           browser->GetHost()->SendMouseClickEvent(mouse_event, MBT_LEFT, false,
734                                                   1);
735         }
736         break;
737       case OSR_TEST_POPUP_HIDE_ON_SCROLL:
738         if (StartTest()) {
739           ExpandDropDown();
740           // Wait for the first popup paint to occur
741         } else if (type == PET_POPUP) {
742           CefMouseEvent mouse_event;
743           mouse_event.x = mouse_event.y = 1;
744           mouse_event.modifiers = 0;
745           browser->GetHost()->SendMouseWheelEvent(mouse_event, 0, -10);
746         }
747         break;
748       case OSR_TEST_POPUP_HIDE_ON_BLUR:
749         if (StartTest()) {
750           ExpandDropDown();
751           // Wait for the first popup paint to occur
752         } else if (type == PET_POPUP) {
753           browser->GetHost()->SetFocus(false);
754         }
755         break;
756       case OSR_TEST_POPUP_HIDE_ON_ESC:
757         if (StartTest()) {
758           ExpandDropDown();
759           // Wait for the first popup paint to occur
760         } else if (type == PET_POPUP) {
761 #if defined(OS_WIN)
762           SendKeyEvent(browser, VK_ESCAPE);
763 #elif defined(OS_MAC) || defined(OS_LINUX)
764           SendKeyEvent(browser, kNativeKeyEscape, VKEY_ESCAPE);
765 #else
766 #error "Unsupported platform"
767 #endif
768         }
769         break;
770       case OSR_TEST_POPUP_SHOW:
771       case OSR_TEST_POPUP_SIZE:
772         if (StartTest()) {
773           ExpandDropDown();
774         }
775         break;
776       case OSR_TEST_POPUP_PAINT:
777         if (StartTest()) {
778           ExpandDropDown();
779         } else if (type == PET_POPUP) {
780           EXPECT_EQ(dirtyRects.size(), 1U);
781           const CefRect& expanded_select_rect =
782               GetScaledRect(kExpandedSelectRect);
783           EXPECT_EQ(0, dirtyRects[0].x);
784           EXPECT_EQ(0, dirtyRects[0].y);
785           if (ExpectComputedPopupSize()) {
786             EXPECT_EQ(expanded_select_rect.width, dirtyRects[0].width);
787             EXPECT_EQ(expanded_select_rect.height, dirtyRects[0].height);
788           } else {
789             EXPECT_GT(dirtyRects[0].width, kExpandedSelectRect.width);
790             EXPECT_GT(dirtyRects[0].height, kExpandedSelectRect.height);
791           }
792 
793           // Unselected option background color is cyan.
794           // Go down 100 pixels to skip the selected option and over 5 pixels to
795           // avoid hitting the border.
796           const uint32 offset = dirtyRects[0].width * 100 + 5;
797           EXPECT_EQ(0xff00ffff,
798                     *(reinterpret_cast<const uint32*>(buffer) + offset));
799 
800           if (ExpectComputedPopupSize()) {
801             EXPECT_EQ(expanded_select_rect.width, width);
802             EXPECT_EQ(expanded_select_rect.height, height);
803           } else {
804             EXPECT_GT(width, kExpandedSelectRect.width);
805             EXPECT_GT(height, kExpandedSelectRect.height);
806           }
807           DestroySucceededTestSoon();
808         }
809         break;
810       case OSR_TEST_POPUP_SCROLL_INSIDE: {
811         static enum {
812           NotStarted,
813           Started,
814           Scrolled
815         } scroll_inside_state = NotStarted;
816         if (StartTest()) {
817           ExpandDropDown();
818           scroll_inside_state = Started;
819         } else if (type == PET_POPUP) {
820           if (scroll_inside_state == Started) {
821             CefMouseEvent mouse_event;
822             mouse_event.x = MiddleX(kExpandedSelectRect);
823             mouse_event.y = MiddleY(kExpandedSelectRect);
824             mouse_event.modifiers = 0;
825             browser->GetHost()->SendMouseWheelEvent(mouse_event, 0, -10);
826             scroll_inside_state = Scrolled;
827           } else if (scroll_inside_state == Scrolled) {
828             const CefRect& expanded_select_rect =
829                 GetScaledRect(kExpandedSelectRect);
830             EXPECT_EQ(dirtyRects.size(), 1U);
831 
832             const int scaled_int_1 = GetScaledInt(1);
833             EXPECT_NEAR(0, dirtyRects[0].x, scaled_int_1);
834             EXPECT_NEAR(0, dirtyRects[0].y, scaled_int_1);
835             if (ExpectComputedPopupSize()) {
836               EXPECT_NEAR(expanded_select_rect.width, dirtyRects[0].width,
837                           scaled_int_1 * 2);
838               EXPECT_NEAR(expanded_select_rect.height, dirtyRects[0].height,
839                           scaled_int_1 * 2);
840             } else {
841               EXPECT_GT(dirtyRects[0].width, kExpandedSelectRect.width);
842               EXPECT_GT(dirtyRects[0].height, kExpandedSelectRect.height);
843             }
844             DestroySucceededTestSoon();
845           }
846         }
847       } break;
848       case OSR_TEST_DRAG_DROP_START_DRAGGING:
849       case OSR_TEST_DRAG_DROP_UPDATE_CURSOR:
850       case OSR_TEST_DRAG_DROP_DROP: {
851         // trigger the StartDragging event
852         if (StartTest()) {
853           // move the mouse over the element to drag
854           CefMouseEvent mouse_event;
855           const CefRect& dragdiv = GetElementBounds("dragdiv");
856           mouse_event.x = MiddleX(dragdiv);
857           mouse_event.y = MiddleY(dragdiv);
858           mouse_event.modifiers = 0;
859           browser->GetHost()->SendMouseMoveEvent(mouse_event, false);
860           // click on the element to drag
861           mouse_event.modifiers = EVENTFLAG_LEFT_MOUSE_BUTTON;
862           browser->GetHost()->SendMouseClickEvent(mouse_event, MBT_LEFT, false,
863                                                   1);
864           // move the mouse to start dragging
865           mouse_event.x -= 5;
866           mouse_event.y -= 5;
867           browser->GetHost()->SendMouseMoveEvent(mouse_event, false);
868         }
869       } break;
870       case OSR_TEST_IME_COMMIT_TEXT: {
871         // trigger the IME Set Composition event
872         if (StartTest()) {
873           // click inside edit box so that text could be entered
874           CefMouseEvent mouse_event;
875           const CefRect& editbox = GetElementBounds("editbox");
876           mouse_event.x = MiddleX(editbox);
877           mouse_event.y = MiddleY(editbox);
878           mouse_event.modifiers = 0;
879           browser->GetHost()->SendMouseClickEvent(mouse_event, MBT_LEFT, false,
880                                                   1);
881           browser->GetHost()->SendMouseClickEvent(mouse_event, MBT_LEFT, true,
882                                                   1);
883 
884           size_t word_length = strlen(kKeyTestWord);
885           // Add some input keys to edit box
886           for (size_t i = 0; i < word_length; ++i) {
887 #if defined(OS_WIN)
888             SendKeyEvent(browser, kKeyTestWord[i]);
889 #elif defined(OS_MAC) || defined(OS_LINUX)
890             SendKeyEvent(browser, kNativeKeyTestCodes[i], kKeyTestCodes[i]);
891 #else
892 #error "Unsupported platform"
893 #endif
894           }
895           // This text should be honored instead of 'ka' added via key events
896           CefString markedText("osrimecommit");
897 
898           CefRange range(0, static_cast<int>(markedText.length()));
899           browser->GetHost()->ImeCommitText(markedText, range, 0);
900 
901           // click button to navigate
902           const CefRect& btnnavigate = GetElementBounds("btnnavigate");
903           mouse_event.x = MiddleX(btnnavigate);
904           mouse_event.y = MiddleY(btnnavigate);
905           browser->GetHost()->SendMouseClickEvent(mouse_event, MBT_LEFT, false,
906                                                   1);
907           browser->GetHost()->SendMouseClickEvent(mouse_event, MBT_LEFT, true,
908                                                   1);
909         }
910       } break;
911       case OSR_TEST_IME_FINISH_COMPOSITION: {
912         // trigger the IME Set Composition event
913         if (StartTest()) {
914           // click inside edit box so that text could be entered
915           CefMouseEvent mouse_event;
916           const CefRect& editbox = GetElementBounds("editbox");
917           mouse_event.x = MiddleX(editbox);
918           mouse_event.y = MiddleY(editbox);
919           mouse_event.modifiers = 0;
920           browser->GetHost()->SendMouseClickEvent(mouse_event, MBT_LEFT, false,
921                                                   1);
922           browser->GetHost()->SendMouseClickEvent(mouse_event, MBT_LEFT, true,
923                                                   1);
924 
925           size_t word_length = strlen(kKeyTestWord);
926           // Add some input keys to edit box
927           for (size_t i = 0; i < word_length; ++i) {
928 #if defined(OS_WIN)
929             SendKeyEvent(browser, kKeyTestWord[i]);
930 #elif defined(OS_MAC) || defined(OS_LINUX)
931             SendKeyEvent(browser, kNativeKeyTestCodes[i], kKeyTestCodes[i]);
932 #else
933 #error "Unsupported platform"
934 #endif
935           }
936 
937           // Finish Composition should set the existing composition
938           browser->GetHost()->ImeFinishComposingText(true);
939 
940           // click button to navigate
941           const CefRect& btnnavigate = GetElementBounds("btnnavigate");
942           mouse_event.x = MiddleX(btnnavigate);
943           mouse_event.y = MiddleY(btnnavigate);
944           browser->GetHost()->SendMouseClickEvent(mouse_event, MBT_LEFT, false,
945                                                   1);
946           browser->GetHost()->SendMouseClickEvent(mouse_event, MBT_LEFT, true,
947                                                   1);
948         }
949       } break;
950       case OSR_TEST_IME_CANCEL_COMPOSITION: {
951         // trigger the IME Set Composition event
952         if (StartTest()) {
953           // click inside edit box so that text could be entered
954           CefMouseEvent mouse_event;
955           const CefRect& editbox = GetElementBounds("editbox");
956           mouse_event.x = MiddleX(editbox);
957           mouse_event.y = MiddleY(editbox);
958           mouse_event.modifiers = 0;
959           browser->GetHost()->SendMouseClickEvent(mouse_event, MBT_LEFT, false,
960                                                   1);
961           browser->GetHost()->SendMouseClickEvent(mouse_event, MBT_LEFT, true,
962                                                   1);
963           // Add some input keys to edit box
964           CefString markedText("か");
965           std::vector<CefCompositionUnderline> underlines;
966 
967           // Use a thin black underline by default.
968           CefRange range(0, static_cast<int>(markedText.length()));
969           cef_composition_underline_t line = {range, 0xFF000000, 0, false};
970           underlines.push_back(line);
971 
972           CefRange replacement_range(0, static_cast<int>(markedText.length()));
973           CefRange selection_range(0, static_cast<int>(markedText.length()));
974 
975           // Composition should be updated
976           browser->GetHost()->ImeSetComposition(
977               markedText, underlines, replacement_range, selection_range);
978 
979           // CancelComposition should clean up the edit text
980           browser->GetHost()->ImeCancelComposition();
981 
982           // click button to navigate and verify
983           const CefRect& btnnavigate = GetElementBounds("btnnavigate");
984           mouse_event.x = MiddleX(btnnavigate);
985           mouse_event.y = MiddleY(btnnavigate);
986           browser->GetHost()->SendMouseClickEvent(mouse_event, MBT_LEFT, false,
987                                                   1);
988           browser->GetHost()->SendMouseClickEvent(mouse_event, MBT_LEFT, true,
989                                                   1);
990         }
991       } break;
992       case OSR_TEST_IME_SET_COMPOSITION: {
993         // trigger the IME Set Composition event
994         if (StartTest()) {
995           // click inside edit box so that text could be entered
996           CefMouseEvent mouse_event;
997           const CefRect& editbox = GetElementBounds("editbox");
998           mouse_event.x = MiddleX(editbox);
999           mouse_event.y = MiddleY(editbox);
1000           mouse_event.modifiers = 0;
1001           browser->GetHost()->SendMouseClickEvent(mouse_event, MBT_LEFT, false,
1002                                                   1);
1003           browser->GetHost()->SendMouseClickEvent(mouse_event, MBT_LEFT, true,
1004                                                   1);
1005 
1006           // Now set some intermediate text composition
1007           CefString markedText("か");
1008           std::vector<CefCompositionUnderline> underlines;
1009 
1010           // Use a thin black underline by default.
1011           CefRange range(0, static_cast<int>(markedText.length()));
1012           cef_composition_underline_t line = {range, 0xFF000000, 0, false};
1013           underlines.push_back(line);
1014 
1015           CefRange replacement_range(0, static_cast<int>(markedText.length()));
1016           CefRange selection_range(0, static_cast<int>(markedText.length()));
1017 
1018           // This should update composition range and
1019           // trigger the compositionRangeChanged callback
1020           browser->GetHost()->ImeSetComposition(
1021               markedText, underlines, replacement_range, selection_range);
1022         }
1023       } break;
1024       case OSR_TEST_TEXT_SELECTION_CHANGE: {
1025         // trigger the text selection changed event
1026         if (StartTest()) {
1027           // click inside list element so text range will be selected.
1028           CefMouseEvent mouse_event;
1029           const CefRect& expected_rect = GetElementBounds("LI11");
1030           mouse_event.x = MiddleX(expected_rect);
1031           mouse_event.y = MiddleY(expected_rect);
1032           mouse_event.modifiers = 0;
1033           browser->GetHost()->SendMouseClickEvent(mouse_event, MBT_LEFT, false,
1034                                                   1);
1035           browser->GetHost()->SendMouseClickEvent(mouse_event, MBT_LEFT, true,
1036                                                   1);
1037         }
1038       } break;
1039       case OSR_TEST_VIRTUAL_KEYBOARD: {
1040         if (StartTest()) {
1041           CefMouseEvent mouse_event;
1042           const CefRect& input = GetElementBounds("email");
1043           mouse_event.x = MiddleX(input);
1044           mouse_event.y = MiddleY(input);
1045           mouse_event.modifiers = 0;
1046           browser->GetHost()->SendMouseClickEvent(mouse_event, MBT_LEFT, false,
1047                                                   1);
1048           browser->GetHost()->SendMouseClickEvent(mouse_event, MBT_LEFT, true,
1049                                                   1);
1050         }
1051       } break;
1052       case OSR_TEST_TOUCH_START:
1053       case OSR_TEST_TOUCH_MOVE:
1054       case OSR_TEST_TOUCH_END:
1055       case OSR_TEST_TOUCH_CANCEL: {
1056         // We trigger a valid Touch workflow sequence and close the tests
1057         // at seperate points for the 4 cases
1058         if (StartTest()) {
1059           const CefRect& touchdiv = GetElementBounds("touchdiv");
1060           // click inside edit box so that text could be entered
1061           CefTouchEvent touch_event1;
1062           touch_event1.id = 0;
1063           touch_event1.x = MiddleX(touchdiv) - 45;
1064           touch_event1.y = MiddleY(touchdiv);
1065           touch_event1.modifiers = 0;
1066           touch_event1.type = CEF_TET_PRESSED;
1067 
1068           CefTouchEvent touch_event2;
1069           touch_event2.id = 1;
1070           touch_event2.x = MiddleX(touchdiv) + 45;
1071           touch_event2.y = MiddleY(touchdiv);
1072           touch_event2.modifiers = 0;
1073           touch_event2.type = CEF_TET_PRESSED;
1074 
1075           browser->GetHost()->SendTouchEvent(touch_event1);
1076           browser->GetHost()->SendTouchEvent(touch_event2);
1077 
1078           // Move the Touch fingers closer
1079           touch_event1.type = touch_event2.type = CEF_TET_MOVED;
1080           for (size_t i = 0; i < 40; i++) {
1081             touch_event1.x++;
1082             touch_event2.x--;
1083             browser->GetHost()->SendTouchEvent(touch_event1);
1084             browser->GetHost()->SendTouchEvent(touch_event2);
1085           }
1086 
1087           // Now release the Touch fingers or cancel them
1088           if (test_type_ == OSR_TEST_TOUCH_CANCEL)
1089             touch_event1.type = touch_event2.type = CEF_TET_CANCELLED;
1090           else
1091             touch_event1.type = touch_event2.type = CEF_TET_RELEASED;
1092           browser->GetHost()->SendTouchEvent(touch_event1);
1093           browser->GetHost()->SendTouchEvent(touch_event2);
1094         }
1095       } break;
1096       case OSR_TEST_PEN: {
1097         if (StartTest()) {
1098           const CefRect& pointerdiv = GetElementBounds("pointerdiv");
1099           CefTouchEvent touch_event;
1100           touch_event.x = MiddleX(pointerdiv) - 45;
1101           touch_event.y = MiddleY(pointerdiv);
1102           touch_event.type = CEF_TET_PRESSED;
1103           touch_event.pointer_type = CEF_POINTER_TYPE_PEN;
1104 
1105           browser->GetHost()->SendTouchEvent(touch_event);
1106 
1107           touch_event.type = CEF_TET_MOVED;
1108           for (size_t i = 0; i < 40; i++) {
1109             touch_event.x++;
1110             browser->GetHost()->SendTouchEvent(touch_event);
1111           }
1112 
1113           touch_event.type = CEF_TET_RELEASED;
1114           browser->GetHost()->SendTouchEvent(touch_event);
1115         }
1116       } break;
1117       default:
1118         break;
1119     }
1120   }
1121 
OnSetFocus(CefRefPtr<CefBrowser> browser,FocusSource source)1122   bool OnSetFocus(CefRefPtr<CefBrowser> browser, FocusSource source) override {
1123     if (source == FOCUS_SOURCE_NAVIGATION) {
1124       got_navigation_focus_event_.yes();
1125 
1126       // Ignore focus from the original navigation when we're testing focus
1127       // event delivery.
1128       if (test_type_ == OSR_TEST_FOCUS)
1129         return true;
1130       return false;
1131     }
1132 
1133     EXPECT_EQ(source, FOCUS_SOURCE_SYSTEM);
1134     got_system_focus_event_.yes();
1135     return false;
1136   }
1137 
OnTakeFocus(CefRefPtr<CefBrowser> browser,bool next)1138   void OnTakeFocus(CefRefPtr<CefBrowser> browser, bool next) override {
1139     if (test_type_ == OSR_TEST_TAKE_FOCUS) {
1140       EXPECT_TRUE(true);
1141       DestroySucceededTestSoon();
1142     }
1143   }
1144 
OnGotFocus(CefRefPtr<CefBrowser> browser)1145   void OnGotFocus(CefRefPtr<CefBrowser> browser) override {
1146     if (test_type_ == OSR_TEST_GOT_FOCUS) {
1147       EXPECT_TRUE(true);
1148       DestroySucceededTestSoon();
1149     }
1150   }
1151 
OnCursorChange(CefRefPtr<CefBrowser> browser,CefCursorHandle cursor,cef_cursor_type_t type,const CefCursorInfo & custom_cursor_info)1152   bool OnCursorChange(CefRefPtr<CefBrowser> browser,
1153                       CefCursorHandle cursor,
1154                       cef_cursor_type_t type,
1155                       const CefCursorInfo& custom_cursor_info) override {
1156     if (test_type_ == OSR_TEST_CURSOR && started()) {
1157       EXPECT_EQ(CT_HAND, type);
1158       EXPECT_EQ(nullptr, custom_cursor_info.buffer);
1159       DestroySucceededTestSoon();
1160     }
1161     return true;
1162   }
1163 
OnImeCompositionRangeChanged(CefRefPtr<CefBrowser> browser,const CefRange & range,const CefRenderHandler::RectList & bounds)1164   void OnImeCompositionRangeChanged(
1165       CefRefPtr<CefBrowser> browser,
1166       const CefRange& range,
1167       const CefRenderHandler::RectList& bounds) override {
1168     if (test_type_ == OSR_TEST_IME_SET_COMPOSITION && started()) {
1169       EXPECT_EQ(range.from, 0);
1170       EXPECT_EQ(range.to, 1);
1171       EXPECT_EQ(1U, bounds.size());
1172       DestroySucceededTestSoon();
1173     }
1174   }
1175 
StartDragging(CefRefPtr<CefBrowser> browser,CefRefPtr<CefDragData> drag_data,CefRenderHandler::DragOperationsMask allowed_ops,int x,int y)1176   bool StartDragging(CefRefPtr<CefBrowser> browser,
1177                      CefRefPtr<CefDragData> drag_data,
1178                      CefRenderHandler::DragOperationsMask allowed_ops,
1179                      int x,
1180                      int y) override {
1181     if (test_type_ == OSR_TEST_DRAG_DROP_START_DRAGGING && started()) {
1182       // Verify the drag image representation.
1183       const CefRect& dragdiv = GetElementBounds("dragdiv");
1184       EXPECT_TRUE(drag_data->HasImage());
1185       CefRefPtr<CefImage> image = drag_data->GetImage();
1186       EXPECT_TRUE(image.get() != nullptr);
1187       if (image.get()) {
1188         // Drag image height seems to always be + 1px greater than the drag rect
1189         // on Linux. Therefore allow it to be +/- 1px.
1190         EXPECT_NEAR(static_cast<int>(image->GetWidth()), dragdiv.width, 1);
1191         EXPECT_NEAR(static_cast<int>(image->GetHeight()), dragdiv.height, 1);
1192       }
1193       // During testing hotspot (x, y) was (15, 23) at 1x scale and (15, 18) at
1194       // 2x scale. Since the mechanism for determining this position is unclear
1195       // test only that it falls within the rect boundaries.
1196       CefPoint hotspot = drag_data->GetImageHotspot();
1197       EXPECT_GT(hotspot.x, 0);
1198       EXPECT_LT(hotspot.x, GetScaledInt(dragdiv.width));
1199       EXPECT_GT(hotspot.y, 0);
1200       EXPECT_LT(hotspot.y, GetScaledInt(dragdiv.height));
1201 
1202       DestroySucceededTestSoon();
1203       return false;
1204     } else if ((test_type_ == OSR_TEST_DRAG_DROP_UPDATE_CURSOR ||
1205                 test_type_ == OSR_TEST_DRAG_DROP_DROP) &&
1206                started()) {
1207       // place the mouse over the drop area to trigger UpdateDragCursor
1208       CefRefPtr<CefDragData> data = drag_data->Clone();
1209       data->ResetFileContents();
1210       CefMouseEvent ev;
1211       const CefRect& dragdiv = GetElementBounds("dragdiv");
1212       ev.x = MiddleX(dragdiv) - 5;
1213       ev.y = MiddleY(dragdiv) - 5;
1214       ev.modifiers = EVENTFLAG_LEFT_MOUSE_BUTTON;
1215       browser->GetHost()->DragTargetDragEnter(data, ev, allowed_ops);
1216 
1217       const CefRect& dropdiv = GetElementBounds("dropdiv");
1218       ev.x = MiddleX(dropdiv);
1219       ev.y = MiddleY(dropdiv);
1220       browser->GetHost()->SendMouseMoveEvent(ev, false);
1221       browser->GetHost()->DragTargetDragOver(ev, allowed_ops);
1222 
1223       ev.x += 5;
1224       ev.y += 5;
1225       browser->GetHost()->SendMouseMoveEvent(ev, false);
1226       browser->GetHost()->DragTargetDragOver(ev, allowed_ops);
1227       return true;
1228     }
1229     return false;
1230   }
1231 
UpdateDragCursor(CefRefPtr<CefBrowser> browser,DragOperation operation)1232   void UpdateDragCursor(CefRefPtr<CefBrowser> browser,
1233                         DragOperation operation) override {
1234     if (test_type_ == OSR_TEST_DRAG_DROP_UPDATE_CURSOR && started()) {
1235       if (operation != DRAG_OPERATION_NONE) {
1236         const CefRect& dropdiv = GetElementBounds("dropdiv");
1237         browser->GetHost()->DragSourceEndedAt(
1238             MiddleX(dropdiv), MiddleY(dropdiv), DRAG_OPERATION_NONE);
1239         browser->GetHost()->DragSourceSystemDragEnded();
1240         DestroySucceededTestSoon();
1241       }
1242     } else if (test_type_ == OSR_TEST_DRAG_DROP_DROP && started()) {
1243       // Don't end the drag multiple times.
1244       if (got_update_cursor_)
1245         return;
1246       got_update_cursor_.yes();
1247 
1248       CefMouseEvent ev;
1249       const CefRect& dropdiv = GetElementBounds("dropdiv");
1250       ev.x = MiddleX(dropdiv);
1251       ev.y = MiddleY(dropdiv);
1252       ev.modifiers = 0;
1253       browser->GetHost()->SendMouseClickEvent(ev, MBT_LEFT, true, 1);
1254       browser->GetHost()->DragTargetDrop(ev);
1255       browser->GetHost()->DragSourceEndedAt(ev.x, ev.y, operation);
1256       browser->GetHost()->DragSourceSystemDragEnded();
1257     }
1258   }
1259 
OnTextSelectionChanged(CefRefPtr<CefBrowser> browser,const CefString & selected_text,const CefRange & selected_range)1260   void OnTextSelectionChanged(CefRefPtr<CefBrowser> browser,
1261                               const CefString& selected_text,
1262                               const CefRange& selected_range) override {
1263     if (test_type_ == OSR_TEST_TEXT_SELECTION_CHANGE && started()) {
1264       if (!got_initial_text_selection_event_) {
1265         got_initial_text_selection_event_.yes();
1266       } else {
1267         EXPECT_STREQ("SELECTED_TEXT_RANGE", selected_text.ToString().c_str());
1268         DestroySucceededTestSoon();
1269       }
1270     }
1271   }
1272 
OnVirtualKeyboardRequested(CefRefPtr<CefBrowser> browser,TextInputMode input_mode)1273   void OnVirtualKeyboardRequested(CefRefPtr<CefBrowser> browser,
1274                                   TextInputMode input_mode) override {
1275     if (test_type_ == OSR_TEST_VIRTUAL_KEYBOARD && started()) {
1276       if (!got_virtual_keyboard_event_.isSet()) {
1277         got_virtual_keyboard_event_.yes();
1278         EXPECT_EQ(CEF_TEXT_INPUT_MODE_EMAIL, input_mode);
1279 
1280         CefMouseEvent mouse_event;
1281         const CefRect& input = GetElementBounds("LI01");
1282         mouse_event.x = MiddleX(input);
1283         mouse_event.y = MiddleY(input);
1284         mouse_event.modifiers = 0;
1285         browser->GetHost()->SendMouseClickEvent(mouse_event, MBT_LEFT, false,
1286                                                 1);
1287         browser->GetHost()->SendMouseClickEvent(mouse_event, MBT_LEFT, true, 1);
1288       } else {
1289         EXPECT_EQ(CEF_TEXT_INPUT_MODE_NONE, input_mode);
1290         DestroySucceededTestSoon();
1291       }
1292     }
1293   }
1294 
OnTooltip(CefRefPtr<CefBrowser> browser,CefString & text)1295   bool OnTooltip(CefRefPtr<CefBrowser> browser, CefString& text) override {
1296     if (test_type_ == OSR_TEST_TOOLTIP && started()) {
1297       EXPECT_STREQ("EXPECTED_TOOLTIP", text.ToString().c_str());
1298       DestroySucceededTestSoon();
1299     }
1300     return false;
1301   }
1302 
OnBeforeContextMenu(CefRefPtr<CefBrowser> browser,CefRefPtr<CefFrame> frame,CefRefPtr<CefContextMenuParams> params,CefRefPtr<CefMenuModel> model)1303   void OnBeforeContextMenu(CefRefPtr<CefBrowser> browser,
1304                            CefRefPtr<CefFrame> frame,
1305                            CefRefPtr<CefContextMenuParams> params,
1306                            CefRefPtr<CefMenuModel> model) override {
1307     if (!started())
1308       return;
1309     if (test_type_ == OSR_TEST_CLICK_RIGHT) {
1310       const CefRect& expected_rect = GetElementBounds("LI04");
1311       EXPECT_EQ(params->GetXCoord(), MiddleX(expected_rect));
1312       EXPECT_EQ(params->GetYCoord(), MiddleY(expected_rect));
1313       DestroySucceededTestSoon();
1314     } else if (test_type_ == OSR_TEST_CONTEXT_MENU) {
1315       // This test will pass if it does not crash on destruction
1316       DestroySucceededTestSoon();
1317     }
1318   }
1319 
1320   // OSRTestHandler functions
CreateOSRBrowser(const CefString & url)1321   void CreateOSRBrowser(const CefString& url) {
1322     CefWindowInfo windowInfo;
1323     CefBrowserSettings settings;
1324 
1325     if (test_type_ != OSR_TEST_TRANSPARENCY) {
1326       // Explicitly set an opaque background color to disable transparency.
1327       settings.background_color = CefColorSetARGB(255, 255, 255, 255);
1328     }
1329 
1330 #if defined(OS_WIN)
1331     windowInfo.SetAsWindowless(GetDesktopWindow());
1332 #elif defined(OS_MAC)
1333     // An actual vies is needed only for the ContextMenu test. The menu runner
1334     // checks if the view is not nil before showing the context menu.
1335     if (test_type_ == OSR_TEST_CONTEXT_MENU)
1336       windowInfo.SetAsWindowless(osr_unittests::GetFakeView());
1337     else
1338       windowInfo.SetAsWindowless(kNullWindowHandle);
1339 #elif defined(OS_LINUX)
1340     windowInfo.SetAsWindowless(kNullWindowHandle);
1341 #else
1342 #error "Unsupported platform"
1343 #endif
1344     CefBrowserHost::CreateBrowser(windowInfo, this, url, settings, nullptr,
1345                                   nullptr);
1346   }
1347 
GetScaledRect(const CefRect & rect) const1348   CefRect GetScaledRect(const CefRect& rect) const {
1349     return client::LogicalToDevice(rect, scale_factor_);
1350   }
1351 
GetScaledInt(int value) const1352   int GetScaledInt(int value) const {
1353     return client::LogicalToDevice(value, scale_factor_);
1354   }
1355 
GetElementBounds(const std::string & id)1356   CefRect GetElementBounds(const std::string& id) {
1357     ElementBoundsMap::const_iterator it = element_bounds_.find(id);
1358     if (it != element_bounds_.end()) {
1359       return it->second;
1360     }
1361     return CefRect();
1362   }
1363 
IsFullRepaint(const CefRect & rc,int width,int height)1364   static bool IsFullRepaint(const CefRect& rc, int width, int height) {
1365     return rc.width == width && rc.height == height;
1366   }
1367 
IsBackgroundInBuffer(const uint32 * buffer,size_t size,uint32 rgba)1368   static bool IsBackgroundInBuffer(const uint32* buffer,
1369                                    size_t size,
1370                                    uint32 rgba) {
1371     for (size_t i = 0; i < size; i++) {
1372       if (buffer[i] != rgba) {
1373         return false;
1374       }
1375     }
1376     return true;
1377   }
1378 
MiddleX(const CefRect & rect)1379   static inline int MiddleX(const CefRect& rect) {
1380     return rect.x + rect.width / 2;
1381   }
1382 
MiddleY(const CefRect & rect)1383   static inline int MiddleY(const CefRect& rect) {
1384     return rect.y + rect.height / 2;
1385   }
1386 
ExpectComputedPopupSize() const1387   bool ExpectComputedPopupSize() const {
1388     // The device scale factor is ignored in Blink when computing
1389     // the default form control font size (see https://crbug.com/674663#c11).
1390     // This results in better font size display but also means that we won't
1391     // get the expected (scaled) width/height value for non-1.0 scale factor
1392     // select popups.
1393     // The non-1.0 scale factor size is off by a few pixels so we can't perform
1394     // an exact comparison.
1395     return scale_factor_ == 1.0;
1396   }
1397 
DestroySucceededTestSoon()1398   void DestroySucceededTestSoon() {
1399     if (succeeded())
1400       return;
1401     if (++event_count_ == event_total_) {
1402       CefPostTask(TID_UI, base::BindOnce(&OSRTestHandler::DestroyTest, this));
1403     }
1404   }
1405 
DestroyTest()1406   void DestroyTest() override {
1407     // Always get the OnSetFocus call for the initial navigation.
1408     EXPECT_TRUE(got_navigation_focus_event_);
1409 
1410     if (test_type_ == OSR_TEST_FOCUS || (test_type_ >= OSR_TEST_POPUP_FIRST &&
1411                                          test_type_ <= OSR_TEST_POPUP_LAST)) {
1412       // SetFocus is called by the system when we explicitly set the focus and
1413       // when popups are dismissed.
1414       EXPECT_TRUE(got_system_focus_event_);
1415     } else if (test_type_ == OSR_TEST_TEXT_SELECTION_CHANGE) {
1416       EXPECT_TRUE(got_initial_text_selection_event_);
1417     } else {
1418       EXPECT_FALSE(got_system_focus_event_);
1419     }
1420 
1421     RoutingTestHandler::DestroyTest();
1422   }
1423 
ExpandDropDown()1424   void ExpandDropDown() {
1425     GetBrowser()->GetHost()->SetFocus(true);
1426     CefMouseEvent mouse_event;
1427 
1428     const CefRect& LI11select = GetElementBounds("LI11select");
1429     mouse_event.x = MiddleX(LI11select);
1430     mouse_event.y = MiddleY(LI11select);
1431     mouse_event.modifiers = 0;
1432     GetBrowser()->GetHost()->SendMouseClickEvent(mouse_event, MBT_LEFT, false,
1433                                                  1);
1434   }
1435 
SendKeyEvent(CefRefPtr<CefBrowser> browser,unsigned int native_key_code,int key_code)1436   void SendKeyEvent(CefRefPtr<CefBrowser> browser,
1437 #if defined(OS_LINUX) || defined(OS_MAC)
1438                     unsigned int native_key_code,
1439 #endif
1440                     int key_code) {
1441     CefKeyEvent event;
1442     event.is_system_key = false;
1443     event.modifiers = 0;
1444 
1445 #if defined(OS_WIN)
1446     BYTE VkCode = LOBYTE(VkKeyScanA(key_code));
1447     UINT scanCode = MapVirtualKey(VkCode, MAPVK_VK_TO_VSC);
1448     event.native_key_code = (scanCode << 16) |  // key scan code
1449                             1;                  // key repeat count
1450     event.windows_key_code = VkCode;
1451 #elif defined(OS_MAC)
1452     event.native_key_code = native_key_code;
1453     // Note that this is only correct for lower-case characters. If |key_code|
1454     // was an upper-case character then |event.character| would be the upper-
1455     // case character and |event.unmodified_character| would be the lower-case
1456     // character (e.g. the character without the shift modifier applied).
1457     event.character = event.unmodified_character = key_code;
1458 #elif defined(OS_LINUX)
1459     event.native_key_code = native_key_code;
1460     event.windows_key_code = key_code;
1461     event.character = event.unmodified_character = native_key_code;
1462 #else
1463     NOTREACHED();
1464 #endif
1465     event.type = KEYEVENT_RAWKEYDOWN;
1466     browser->GetHost()->SendKeyEvent(event);
1467 
1468 #if defined(OS_WIN)
1469     event.windows_key_code = key_code;
1470 #endif
1471     event.type = KEYEVENT_CHAR;
1472     browser->GetHost()->SendKeyEvent(event);
1473 
1474 #if defined(OS_WIN)
1475     event.windows_key_code = VkCode;
1476     // bits 30 and 31 should be always 1 for WM_KEYUP
1477     event.native_key_code |= 0xC0000000;
1478 #endif
1479     event.type = KEYEVENT_KEYUP;
1480     browser->GetHost()->SendKeyEvent(event);
1481   }
1482 
1483   // true if the events for this test are already sent
started()1484   bool started() { return started_; }
1485 
1486   // true if the exit point was reached, even the result is not
1487   // the expected one
succeeded()1488   bool succeeded() { return (event_count_ == event_total_); }
1489 
1490   // will mark test as started and will return true only the first time
1491   // it is called
StartTest()1492   bool StartTest() {
1493     if (started_)
1494       return false;
1495     started_ = true;
1496     return true;
1497   }
1498 
1499  private:
1500   OSRTestType test_type_;
1501   float scale_factor_;
1502   int event_count_;
1503   int event_total_;
1504   bool started_;
1505   cef_touch_event_type_t touch_state_;
1506   TrackCallback got_update_cursor_;
1507   TrackCallback got_navigation_focus_event_;
1508   TrackCallback got_system_focus_event_;
1509   TrackCallback got_initial_text_selection_event_;
1510   TrackCallback got_virtual_keyboard_event_;
1511 
1512   typedef std::map<std::string, CefRect> ElementBoundsMap;
1513   ElementBoundsMap element_bounds_;
1514 
1515   IMPLEMENT_REFCOUNTING(OSRTestHandler);
1516 };
1517 
1518 }  // namespace
1519 
1520 // generic test
1521 #define OSR_TEST(name, test_mode, scale_factor)      \
1522   TEST(OSRTest, name) {                              \
1523     CefRefPtr<OSRTestHandler> handler =              \
1524         new OSRTestHandler(test_mode, scale_factor); \
1525     handler->ExecuteTest();                          \
1526     EXPECT_TRUE(handler->succeeded());               \
1527     ReleaseAndWaitForDestructor(handler);            \
1528   }
1529 
1530 // tests
1531 OSR_TEST(Windowless, OSR_TEST_IS_WINDOWLESS, 1.0f)
1532 OSR_TEST(Windowless2x, OSR_TEST_IS_WINDOWLESS, 2.0f)
1533 OSR_TEST(Focus, OSR_TEST_FOCUS, 1.0f)
1534 OSR_TEST(Focus2x, OSR_TEST_FOCUS, 2.0f)
1535 OSR_TEST(TakeFocus, OSR_TEST_TAKE_FOCUS, 1.0f)
1536 OSR_TEST(TakeFocus2x, OSR_TEST_TAKE_FOCUS, 2.0f)
1537 OSR_TEST(GotFocus, OSR_TEST_GOT_FOCUS, 1.0f)
1538 OSR_TEST(GotFocus2x, OSR_TEST_GOT_FOCUS, 2.0f)
1539 OSR_TEST(Paint, OSR_TEST_PAINT, 1.0f)
1540 OSR_TEST(Paint2x, OSR_TEST_PAINT, 2.0f)
1541 OSR_TEST(TransparentPaint, OSR_TEST_TRANSPARENCY, 1.0f)
1542 OSR_TEST(TransparentPaint2x, OSR_TEST_TRANSPARENCY, 2.0f)
1543 OSR_TEST(Cursor, OSR_TEST_CURSOR, 1.0f)
1544 OSR_TEST(Cursor2x, OSR_TEST_CURSOR, 2.0f)
1545 OSR_TEST(MouseMove, OSR_TEST_MOUSE_MOVE, 1.0f)
1546 OSR_TEST(MouseMove2x, OSR_TEST_MOUSE_MOVE, 2.0f)
1547 OSR_TEST(MouseRightClick, OSR_TEST_CLICK_RIGHT, 1.0f)
1548 OSR_TEST(MouseRightClick2x, OSR_TEST_CLICK_RIGHT, 2.0f)
1549 OSR_TEST(MouseLeftClick, OSR_TEST_CLICK_LEFT, 1.0f)
1550 OSR_TEST(MouseLeftClick2x, OSR_TEST_CLICK_LEFT, 2.0f)
1551 OSR_TEST(ScreenPoint, OSR_TEST_SCREEN_POINT, 1.0f)
1552 OSR_TEST(ScreenPoint2x, OSR_TEST_SCREEN_POINT, 2.0f)
1553 OSR_TEST(Resize, OSR_TEST_RESIZE, 1.0f)
1554 OSR_TEST(Resize2x, OSR_TEST_RESIZE, 2.0f)
1555 OSR_TEST(Invalidate, OSR_TEST_INVALIDATE, 1.0f)
1556 OSR_TEST(Invalidate2x, OSR_TEST_INVALIDATE, 2.0f)
1557 OSR_TEST(KeyEvents, OSR_TEST_KEY_EVENTS, 1.0f)
1558 OSR_TEST(KeyEvents2x, OSR_TEST_KEY_EVENTS, 2.0f)
1559 OSR_TEST(Tooltip, OSR_TEST_TOOLTIP, 1.0f)
1560 OSR_TEST(Tooltip2x, OSR_TEST_TOOLTIP, 2.0f)
1561 OSR_TEST(Scrolling, OSR_TEST_SCROLLING, 1.0f)
1562 OSR_TEST(Scrolling2x, OSR_TEST_SCROLLING, 2.0f)
1563 OSR_TEST(ContextMenu, OSR_TEST_CONTEXT_MENU, 1.0f)
1564 OSR_TEST(ContextMenu2x, OSR_TEST_CONTEXT_MENU, 2.0f)
1565 OSR_TEST(PopupPaint, OSR_TEST_POPUP_PAINT, 1.0f)
1566 OSR_TEST(PopupPaint2x, OSR_TEST_POPUP_PAINT, 2.0f)
1567 OSR_TEST(PopupShow, OSR_TEST_POPUP_SHOW, 1.0f)
1568 OSR_TEST(PopupShow2x, OSR_TEST_POPUP_SHOW, 2.0f)
1569 OSR_TEST(PopupSize, OSR_TEST_POPUP_SIZE, 1.0f)
1570 OSR_TEST(PopupSize2x, OSR_TEST_POPUP_SIZE, 2.0f)
1571 OSR_TEST(PopupHideOnBlur, OSR_TEST_POPUP_HIDE_ON_BLUR, 1.0f)
1572 OSR_TEST(PopupHideOnBlur2x, OSR_TEST_POPUP_HIDE_ON_BLUR, 2.0f)
1573 OSR_TEST(PopupHideOnClick, OSR_TEST_POPUP_HIDE_ON_CLICK, 1.0f)
1574 OSR_TEST(PopupHideOnClick2x, OSR_TEST_POPUP_HIDE_ON_CLICK, 2.0f)
1575 OSR_TEST(PopupHideOnScroll, OSR_TEST_POPUP_HIDE_ON_SCROLL, 1.0f)
1576 OSR_TEST(PopupHideOnScroll2x, OSR_TEST_POPUP_HIDE_ON_SCROLL, 2.0f)
1577 OSR_TEST(PopupHideOnEsc, OSR_TEST_POPUP_HIDE_ON_ESC, 1.0f)
1578 OSR_TEST(PopupHideOnEsc2x, OSR_TEST_POPUP_HIDE_ON_ESC, 2.0f)
1579 OSR_TEST(PopupScrollInside, OSR_TEST_POPUP_SCROLL_INSIDE, 1.0f)
1580 OSR_TEST(PopupScrollInside2x, OSR_TEST_POPUP_SCROLL_INSIDE, 2.0f)
1581 OSR_TEST(DragDropStartDragging, OSR_TEST_DRAG_DROP_START_DRAGGING, 1.0f)
1582 OSR_TEST(DragDropStartDragging2x, OSR_TEST_DRAG_DROP_START_DRAGGING, 2.0f)
1583 OSR_TEST(DragDropUpdateCursor, OSR_TEST_DRAG_DROP_UPDATE_CURSOR, 1.0f)
1584 OSR_TEST(DragDropUpdateCursor2x, OSR_TEST_DRAG_DROP_UPDATE_CURSOR, 2.0f)
1585 OSR_TEST(DragDropDropElement, OSR_TEST_DRAG_DROP_DROP, 1.0f)
1586 OSR_TEST(DragDropDropElement2x, OSR_TEST_DRAG_DROP_DROP, 2.0f)
1587 OSR_TEST(IMESetComposition, OSR_TEST_IME_SET_COMPOSITION, 1.0f)
1588 OSR_TEST(IMESetComposition2x, OSR_TEST_IME_SET_COMPOSITION, 2.0f)
1589 OSR_TEST(IMECommitText, OSR_TEST_IME_COMMIT_TEXT, 1.0f)
1590 OSR_TEST(IMECommitText2x, OSR_TEST_IME_COMMIT_TEXT, 2.0f)
1591 OSR_TEST(IMEFinishComposition, OSR_TEST_IME_FINISH_COMPOSITION, 1.0f)
1592 OSR_TEST(IMEFinishComposition2x, OSR_TEST_IME_FINISH_COMPOSITION, 2.0f)
1593 OSR_TEST(IMECancelComposition, OSR_TEST_IME_CANCEL_COMPOSITION, 1.0f)
1594 OSR_TEST(IMECancelComposition2x, OSR_TEST_IME_CANCEL_COMPOSITION, 2.0f)
1595 OSR_TEST(TextSelectionChanged, OSR_TEST_TEXT_SELECTION_CHANGE, 1.0f)
1596 OSR_TEST(TextSelectionChanged2x, OSR_TEST_TEXT_SELECTION_CHANGE, 2.0f)
1597 OSR_TEST(VirtualKeyboard, OSR_TEST_VIRTUAL_KEYBOARD, 1.0f)
1598 OSR_TEST(TouchStart, OSR_TEST_TOUCH_START, 1.0f)
1599 OSR_TEST(TouchStart2X, OSR_TEST_TOUCH_START, 2.0f)
1600 OSR_TEST(TouchMove, OSR_TEST_TOUCH_MOVE, 1.0f)
1601 OSR_TEST(TouchMove2X, OSR_TEST_TOUCH_MOVE, 2.0f)
1602 OSR_TEST(TouchEnd, OSR_TEST_TOUCH_END, 1.0f)
1603 OSR_TEST(TouchEnd2X, OSR_TEST_TOUCH_END, 2.0f)
1604 OSR_TEST(TouchCancel, OSR_TEST_TOUCH_CANCEL, 1.0f)
1605 OSR_TEST(TouchCancel2X, OSR_TEST_TOUCH_CANCEL, 2.0f)
1606 OSR_TEST(PenEvent, OSR_TEST_PEN, 1.0f)
1607