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

Unified Diff: chrome/browser/ui/views/ime/input_ime_apitest_nonchromeos.cc

Issue 2120823003: Fix InputImeApiTest.SendKeyEventsOnNormalPage trybot failure. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | testing/buildbot/filters/site-per-process.browser_tests.filter » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/ime/input_ime_apitest_nonchromeos.cc
diff --git a/chrome/browser/ui/views/ime/input_ime_apitest_nonchromeos.cc b/chrome/browser/ui/views/ime/input_ime_apitest_nonchromeos.cc
index 4fcc232ce932bcb0864106a8d2ef053cccf44125..6243afd7c7cb1a4adc3ffd57c50ddb58b6c39a5f 100644
--- a/chrome/browser/ui/views/ime/input_ime_apitest_nonchromeos.cc
+++ b/chrome/browser/ui/views/ime/input_ime_apitest_nonchromeos.cc
@@ -7,6 +7,7 @@
#include "chrome/browser/extensions/api/input_ime/input_ime_api_nonchromeos.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/ui/browser_window.h"
+#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/ui_test_utils.h"
@@ -16,6 +17,7 @@
#include "ui/base/ime/composition_text.h"
#include "ui/base/ime/dummy_text_input_client.h"
#include "ui/base/ime/input_method.h"
+#include "url/origin.h"
namespace extensions {
@@ -105,9 +107,10 @@ IN_PROC_BROWSER_TEST_F(InputImeApiTest, BasicApiTest) {
input_method->DetachTextInputClient(client2.get());
}
-IN_PROC_BROWSER_TEST_F(InputImeApiTest, SendKeyEvntsOnNormalPage) {
+IN_PROC_BROWSER_TEST_F(InputImeApiTest, SendKeyEventsOnNormalPage) {
// Navigates to special page that sendKeyEvents API has limition with.
- ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL));
+ GURL test_url(chrome::kChromeUINewTabURL);
+ ui_test_utils::NavigateToURL(browser(), test_url);
// Manipulates the focused text input client because the follow cursor
// window requires the text input focus.
ui::InputMethod* input_method =
@@ -122,26 +125,34 @@ IN_PROC_BROWSER_TEST_F(InputImeApiTest, SendKeyEvntsOnNormalPage) {
ASSERT_TRUE(RunExtensionTest("input_ime_nonchromeos")) << message_;
- std::vector<std::unique_ptr<ui::KeyEvent>> key_events;
- key_events.push_back(std::unique_ptr<ui::KeyEvent>(
- new ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE)));
- key_events.push_back(std::unique_ptr<ui::KeyEvent>(
- new ui::KeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_A, ui::EF_NONE)));
- key_events.push_back(std::unique_ptr<ui::KeyEvent>(
- new ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_CONTROL_DOWN)));
- key_events.push_back(std::unique_ptr<ui::KeyEvent>(
- new ui::KeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_A, ui::EF_CONTROL_DOWN)));
- key_events.push_back(std::unique_ptr<ui::KeyEvent>(
- new ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_TAB, ui::EF_NONE)));
-
- EXPECT_TRUE(CompareKeyEvents(key_events, input_method));
+ content::WebContents* web_contents =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ url::Origin origin(web_contents->GetLastCommittedURL());
+
+ // Don't check events if the url has not been correctly set.
+ if (url::Origin(test_url).IsSameOriginWith(origin)) {
+ std::vector<std::unique_ptr<ui::KeyEvent>> key_events;
+ key_events.push_back(std::unique_ptr<ui::KeyEvent>(
+ new ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE)));
+ key_events.push_back(std::unique_ptr<ui::KeyEvent>(
+ new ui::KeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_A, ui::EF_NONE)));
+ key_events.push_back(std::unique_ptr<ui::KeyEvent>(
+ new ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_CONTROL_DOWN)));
+ key_events.push_back(std::unique_ptr<ui::KeyEvent>(new ui::KeyEvent(
+ ui::ET_KEY_RELEASED, ui::VKEY_A, ui::EF_CONTROL_DOWN)));
+ key_events.push_back(std::unique_ptr<ui::KeyEvent>(
+ new ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_TAB, ui::EF_NONE)));
+
+ EXPECT_TRUE(CompareKeyEvents(key_events, input_method));
+ }
input_method->DetachTextInputClient(client.get());
}
IN_PROC_BROWSER_TEST_F(InputImeApiTest, SendKeyEventsOnSpecialPage) {
// Navigates to special page that sendKeyEvents API has limition with.
- ui_test_utils::NavigateToURL(browser(), GURL("chrome://flags"));
+ GURL test_url("chrome://flags");
+ ui_test_utils::NavigateToURL(browser(), test_url);
ui::InputMethod* input_method =
browser()->window()->GetNativeWindow()->GetHost()->GetInputMethod();
@@ -155,13 +166,20 @@ IN_PROC_BROWSER_TEST_F(InputImeApiTest, SendKeyEventsOnSpecialPage) {
ASSERT_TRUE(RunExtensionTest("input_ime_nonchromeos")) << message_;
- std::vector<std::unique_ptr<ui::KeyEvent>> key_events;
- key_events.push_back(std::unique_ptr<ui::KeyEvent>(
- new ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE)));
- key_events.push_back(std::unique_ptr<ui::KeyEvent>(
- new ui::KeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_A, ui::EF_NONE)));
+ content::WebContents* web_contents =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ url::Origin origin(web_contents->GetLastCommittedURL());
- EXPECT_TRUE(CompareKeyEvents(key_events, input_method));
+ // Don't check events if the url has not been correctly set.
+ if (url::Origin(test_url).IsSameOriginWith(origin)) {
+ std::vector<std::unique_ptr<ui::KeyEvent>> key_events;
+ key_events.push_back(std::unique_ptr<ui::KeyEvent>(
+ new ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE)));
+ key_events.push_back(std::unique_ptr<ui::KeyEvent>(
+ new ui::KeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_A, ui::EF_NONE)));
+
+ EXPECT_TRUE(CompareKeyEvents(key_events, input_method));
+ }
input_method->DetachTextInputClient(client.get());
}
« no previous file with comments | « no previous file | testing/buildbot/filters/site-per-process.browser_tests.filter » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698