OLD | NEW |
---|---|
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 "base/prefs/pref_service.h" | 5 #include "base/prefs/pref_service.h" |
6 #include "chrome/browser/chrome_notification_types.h" | |
6 #include "chrome/browser/ui/browser_window.h" | 7 #include "chrome/browser/ui/browser_window.h" |
7 #include "chrome/browser/ui/chrome_pages.h" | 8 #include "chrome/browser/ui/chrome_pages.h" |
8 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 9 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
9 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
10 #include "chrome/common/url_constants.h" | 11 #include "chrome/common/url_constants.h" |
11 #include "chrome/test/base/in_process_browser_test.h" | 12 #include "chrome/test/base/in_process_browser_test.h" |
12 #include "chrome/test/base/interactive_test_utils.h" | 13 #include "chrome/test/base/interactive_test_utils.h" |
13 #include "chrome/test/base/ui_test_utils.h" | 14 #include "chrome/test/base/ui_test_utils.h" |
14 #include "content/public/browser/render_frame_host.h" | 15 #include "content/public/browser/render_frame_host.h" |
15 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 GetActiveFrame(), | 54 GetActiveFrame(), |
54 get_element_id_script, | 55 get_element_id_script, |
55 &element_id)); | 56 &element_id)); |
56 return element_id; | 57 return element_id; |
57 } | 58 } |
58 | 59 |
59 content::RenderFrameHost* GetActiveFrame() { | 60 content::RenderFrameHost* GetActiveFrame() { |
60 return GetActiveWebContents()->GetFocusedFrame(); | 61 return GetActiveWebContents()->GetFocusedFrame(); |
61 } | 62 } |
62 | 63 |
64 content::RenderViewHost* GetRenderViewHost() { | |
msw
2014/08/27 19:01:33
nit: this helper seem unnecessary for one call.
| |
65 return GetActiveWebContents()->GetRenderViewHost(); | |
66 } | |
67 | |
63 content::WebContents* GetActiveWebContents() { | 68 content::WebContents* GetActiveWebContents() { |
64 return browser()->tab_strip_model()->GetActiveWebContents(); | 69 return browser()->tab_strip_model()->GetActiveWebContents(); |
65 } | 70 } |
66 | 71 |
67 // Press and release a key in a particular window. Returns false on error. | 72 // Press and release a key in the browser. This will wait for the element on |
73 // the page to change. | |
68 bool PressKey(ui::KeyboardCode key_code) { | 74 bool PressKey(ui::KeyboardCode key_code) { |
69 return ui_test_utils::SendKeyPressSync(browser(), key_code, | 75 return ui_test_utils::SendKeyPressAndWait( |
70 false, false, false, false); | 76 browser(), |
77 key_code, | |
78 false, | |
79 false, | |
80 false, | |
81 false, | |
82 content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE, | |
83 content::Source<content::RenderViewHost>(GetRenderViewHost())); | |
71 } | 84 } |
72 | 85 |
73 private: | 86 private: |
74 DISALLOW_COPY_AND_ASSIGN(LanguageOptionsWebUITest); | 87 DISALLOW_COPY_AND_ASSIGN(LanguageOptionsWebUITest); |
75 }; | 88 }; |
76 | 89 |
77 } // namespace | 90 } // namespace |
78 | 91 |
79 // This test will verify that the appropriate languages are available. | 92 // This test will verify that the appropriate languages are available. |
80 // This test will also fail if the language page is not loaded because a random | 93 // This test will also fail if the language page is not loaded because a random |
(...skipping 28 matching lines...) Expand all Loading... | |
109 get_children_of_current_element_script, | 122 get_children_of_current_element_script, |
110 &languages)); | 123 &languages)); |
111 EXPECT_EQ("English (United States)SpanishFrench", languages); | 124 EXPECT_EQ("English (United States)SpanishFrench", languages); |
112 } | 125 } |
113 | 126 |
114 // This test will validate that the language webui is accessible through | 127 // This test will validate that the language webui is accessible through |
115 // the keyboard. | 128 // the keyboard. |
116 // This test must be updated if the tab order of the elements on this page | 129 // This test must be updated if the tab order of the elements on this page |
117 // is chagned. | 130 // is chagned. |
118 // flaky: http://crbug.com/405711 | 131 // flaky: http://crbug.com/405711 |
119 IN_PROC_BROWSER_TEST_F(LanguageOptionsWebUITest, | 132 IN_PROC_BROWSER_TEST_F(LanguageOptionsWebUITest, TestListTabAccessibility) { |
120 DISABLED_TestListTabAccessibility) { | |
121 // Verify that the language list is focused by default. | 133 // Verify that the language list is focused by default. |
122 std::string original_id = GetActiveElementId(); | 134 std::string original_id = GetActiveElementId(); |
123 EXPECT_EQ("language-options-list", original_id); | 135 EXPECT_EQ("language-options-list", original_id); |
124 | 136 |
125 // Press tab to select the next element. | 137 // Press tab to select the next element. |
126 ASSERT_TRUE(PressKey(ui::VKEY_TAB)); | 138 ASSERT_TRUE(PressKey(ui::VKEY_TAB)); |
127 | 139 |
128 // Make sure that the element is now the button that is next in the tab order. | 140 // Make sure that the element is now the button that is next in the tab order. |
129 // Checking that the list is no longer selected is not sufficient to validate | 141 // Checking that the list is no longer selected is not sufficient to validate |
130 // this use case because this test should fail if an item inside the list is | 142 // this use case because this test should fail if an item inside the list is |
131 // selected. | 143 // selected. |
132 std::string new_id = GetActiveElementId(); | 144 std::string new_id = GetActiveElementId(); |
133 EXPECT_EQ("language-options-add-button", new_id); | 145 EXPECT_EQ("language-options-add-button", new_id); |
134 } | 146 } |
135 | 147 |
136 } // namespace language_options_ui_test | 148 } // namespace language_options_ui_test |
137 | 149 |
OLD | NEW |