ceftests: Fix OSRTest flakyness
This commit is contained in:
parent
b3f93d506f
commit
59b475790b
|
@ -540,18 +540,7 @@ class DownloadTestHandler : public TestHandler {
|
|||
mouse_event.x = 20;
|
||||
mouse_event.y = 20;
|
||||
mouse_event.modifiers = modifiers;
|
||||
|
||||
// Add some delay to avoid having events dropped or rate limited.
|
||||
CefPostDelayedTask(
|
||||
TID_UI,
|
||||
base::BindOnce(&CefBrowserHost::SendMouseClickEvent, browser->GetHost(),
|
||||
mouse_event, MBT_LEFT, false, 1),
|
||||
50);
|
||||
CefPostDelayedTask(
|
||||
TID_UI,
|
||||
base::BindOnce(&CefBrowserHost::SendMouseClickEvent, browser->GetHost(),
|
||||
mouse_event, MBT_LEFT, true, 1),
|
||||
100);
|
||||
SendMouseClickEvent(browser, mouse_event);
|
||||
}
|
||||
|
||||
const TestMode test_mode_;
|
||||
|
|
|
@ -1883,10 +1883,7 @@ class LoadNavTestHandler : public TestHandler {
|
|||
|
||||
cef_mouse_button_type_t button_type =
|
||||
(mode_ == MIDDLE_CLICK ? MBT_MIDDLE : MBT_LEFT);
|
||||
browser->GetHost()->SendMouseClickEvent(mouse_event, button_type, false,
|
||||
1);
|
||||
browser->GetHost()->SendMouseClickEvent(mouse_event, button_type, true,
|
||||
1);
|
||||
SendMouseClickEvent(browser, mouse_event, button_type);
|
||||
}
|
||||
|
||||
if (cancel_in_open_url_) {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -148,8 +148,7 @@ class PdfViewerTestHandler : public TestHandler, public CefContextMenuHandler {
|
|||
}
|
||||
|
||||
// Send right-click mouse down and mouse up to tigger context menu.
|
||||
browser->GetHost()->SendMouseClickEvent(mouse_event, MBT_RIGHT, false, 1);
|
||||
browser->GetHost()->SendMouseClickEvent(mouse_event, MBT_RIGHT, true, 1);
|
||||
SendMouseClickEvent(browser, mouse_event, MBT_RIGHT);
|
||||
}
|
||||
|
||||
bool RunContextMenu(CefRefPtr<CefBrowser> browser,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "include/base/cef_bind.h"
|
||||
#include "include/base/cef_callback.h"
|
||||
#include "include/cef_parser.h"
|
||||
#include "include/cef_permission_handler.h"
|
||||
#include "include/cef_request_context_handler.h"
|
||||
|
@ -13,6 +13,7 @@
|
|||
#include "include/wrapper/cef_stream_resource_handler.h"
|
||||
#include "tests/ceftests/test_handler.h"
|
||||
#include "tests/ceftests/test_suite.h"
|
||||
#include "tests/ceftests/test_util.h"
|
||||
#include "tests/gtest/include/gtest/gtest.h"
|
||||
#include "tests/shared/browser/client_app_browser.h"
|
||||
|
||||
|
@ -264,18 +265,7 @@ class PermissionPromptTestHandler : public TestHandler,
|
|||
CefMouseEvent mouse_event;
|
||||
mouse_event.x = 20;
|
||||
mouse_event.y = 20;
|
||||
|
||||
// Add some delay to avoid having events dropped or rate limited.
|
||||
CefPostDelayedTask(
|
||||
TID_UI,
|
||||
base::BindOnce(&CefBrowserHost::SendMouseClickEvent, browser->GetHost(),
|
||||
mouse_event, MBT_LEFT, false, 1),
|
||||
50);
|
||||
CefPostDelayedTask(
|
||||
TID_UI,
|
||||
base::BindOnce(&CefBrowserHost::SendMouseClickEvent, browser->GetHost(),
|
||||
mouse_event, MBT_LEFT, true, 1),
|
||||
100);
|
||||
SendMouseClickEvent(browser, mouse_event);
|
||||
}
|
||||
|
||||
CefRefPtr<CefDictionaryValue> ParseURLData(const std::string& url) {
|
||||
|
|
|
@ -324,18 +324,7 @@ class PopupTestHandler : public TestHandler {
|
|||
mouse_event.x = 20;
|
||||
mouse_event.y = 20;
|
||||
mouse_event.modifiers = 0;
|
||||
|
||||
// Add some delay to avoid having events dropped or rate limited.
|
||||
CefPostDelayedTask(
|
||||
TID_UI,
|
||||
base::BindOnce(&CefBrowserHost::SendMouseClickEvent,
|
||||
browser->GetHost(), mouse_event, MBT_LEFT, false, 1),
|
||||
50);
|
||||
CefPostDelayedTask(
|
||||
TID_UI,
|
||||
base::BindOnce(&CefBrowserHost::SendMouseClickEvent,
|
||||
browser->GetHost(), mouse_event, MBT_LEFT, true, 1),
|
||||
100);
|
||||
SendMouseClickEvent(browser, mouse_event);
|
||||
} else {
|
||||
ADD_FAILURE(); // Not reached.
|
||||
}
|
||||
|
|
|
@ -8,9 +8,11 @@
|
|||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "include/base/cef_callback.h"
|
||||
#include "include/cef_base.h"
|
||||
#include "include/cef_command_line.h"
|
||||
#include "include/cef_request_context_handler.h"
|
||||
#include "include/wrapper/cef_closure_task.h"
|
||||
#include "tests/gtest/include/gtest/gtest.h"
|
||||
#include "tests/shared/common/string_util.h"
|
||||
|
||||
|
@ -346,6 +348,20 @@ std::optional<int> GetConfiguredTestTimeout(int timeout_ms) {
|
|||
std::round(static_cast<double>(timeout_ms) * (*multiplier)));
|
||||
}
|
||||
|
||||
void SendMouseClickEvent(CefRefPtr<CefBrowser> browser,
|
||||
const CefMouseEvent& mouse_event,
|
||||
cef_mouse_button_type_t mouse_button_type) {
|
||||
auto host = browser->GetHost();
|
||||
CefPostDelayedTask(TID_UI,
|
||||
base::BindOnce(&CefBrowserHost::SendMouseClickEvent, host,
|
||||
mouse_event, mouse_button_type, false, 1),
|
||||
50);
|
||||
CefPostDelayedTask(TID_UI,
|
||||
base::BindOnce(&CefBrowserHost::SendMouseClickEvent, host,
|
||||
mouse_event, mouse_button_type, true, 1),
|
||||
100);
|
||||
}
|
||||
|
||||
CefRefPtr<CefRequestContext> CreateTestRequestContext(
|
||||
TestRequestContextMode mode,
|
||||
const std::string& cache_path) {
|
||||
|
|
|
@ -102,6 +102,12 @@ bool IgnoreURL(const std::string& url);
|
|||
// if timeouts are disabled.
|
||||
std::optional<int> GetConfiguredTestTimeout(int timeout_ms);
|
||||
|
||||
// Send a mouse click event with the necessary delay to avoid having events
|
||||
// dropped or rate limited.
|
||||
void SendMouseClickEvent(CefRefPtr<CefBrowser> browser,
|
||||
const CefMouseEvent& mouse_event,
|
||||
cef_mouse_button_type_t mouse_button_type = MBT_LEFT);
|
||||
|
||||
// Return a RequestContext object matching the specified |mode|.
|
||||
// |cache_path| may be specified for CUSTOM modes.
|
||||
// Use the RC_TEST_GROUP_BASE macro to test all valid combinations.
|
||||
|
|
|
@ -100,6 +100,11 @@
|
|||
window.testQuery({request: param});
|
||||
}
|
||||
|
||||
function onFocusTest(ev) {
|
||||
if (window.testQuery)
|
||||
window.testQuery({request: "osrfocus" + ev.target.id});
|
||||
}
|
||||
|
||||
function allowDrop(ev) {
|
||||
ev.preventDefault();
|
||||
}
|
||||
|
@ -169,7 +174,7 @@
|
|||
</li>
|
||||
<li id='LI07'>Invalidate should trigger OnPaint once</li>
|
||||
<li id='LI08'>Click and write here with SendKeyEvent to trigger repaints:
|
||||
<input id='editbox' type='text' value='' size="5"></li>
|
||||
<input id='editbox' type='text' value='' size="5" onfocus="onFocusTest(event)"></li>
|
||||
<li id='LI09'>Click here with SendMouseClickEvent to navigate:
|
||||
<input id='btnnavigate' type='button' onclick='navigate()'
|
||||
value='Click here to navigate' /></li>
|
||||
|
|
Loading…
Reference in New Issue