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

Side by Side Diff: chrome/browser/ui/views/find_bar_views_interactive_uitest.cc

Issue 2828163004: Revert of Revert "Revert of Reland: Switch WindowedNotificationObserver to use base::RunLoop. (Closed)
Patch Set: Created 3 years, 8 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 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/macros.h" 5 #include "base/macros.h"
6 #include "base/strings/string_util.h" 6 #include "base/strings/string_util.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 browser()->tab_strip_model()->GetActiveWebContents()); 78 browser()->tab_strip_model()->GetActiveWebContents());
79 ui_test_utils::WindowedNotificationObserverWithDetails 79 ui_test_utils::WindowedNotificationObserverWithDetails
80 <FindNotificationDetails> observer( 80 <FindNotificationDetails> observer(
81 chrome::NOTIFICATION_FIND_RESULT_AVAILABLE, source); 81 chrome::NOTIFICATION_FIND_RESULT_AVAILABLE, source);
82 observer.Wait(); 82 observer.Wait();
83 FindNotificationDetails details; 83 FindNotificationDetails details;
84 EXPECT_TRUE(observer.GetDetailsFor(source.map_key(), &details)); 84 EXPECT_TRUE(observer.GetDetailsFor(source.map_key(), &details));
85 return details; 85 return details;
86 } 86 }
87 87
88 FindNotificationDetails WaitForFinalFindResult() {
89 while (true) {
90 auto details = WaitForFindResult();
91 if (details.final_update())
92 return details;
93 }
94 }
95
96 private: 88 private:
97 DISALLOW_COPY_AND_ASSIGN(FindInPageTest); 89 DISALLOW_COPY_AND_ASSIGN(FindInPageTest);
98 }; 90 };
99 91
100 // Flaky because the test server fails to start? See: http://crbug.com/96594. 92 // Flaky because the test server fails to start? See: http://crbug.com/96594.
101 IN_PROC_BROWSER_TEST_F(FindInPageTest, CrashEscHandlers) { 93 IN_PROC_BROWSER_TEST_F(FindInPageTest, CrashEscHandlers) {
102 ASSERT_TRUE(embedded_test_server()->Start()); 94 ASSERT_TRUE(embedded_test_server()->Start());
103 95
104 // First we navigate to our test page (tab A). 96 // First we navigate to our test page (tab A).
105 GURL url = embedded_test_server()->GetURL(kSimplePage); 97 GURL url = embedded_test_server()->GetURL(kSimplePage);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 ASSERT_GE(match_count, 3); 176 ASSERT_GE(match_count, 3);
185 // Avoid GetViewByID on BrowserView; the find bar is outside its hierarchy. 177 // Avoid GetViewByID on BrowserView; the find bar is outside its hierarchy.
186 FindBarView* find_bar_view = GetFindBarView(); 178 FindBarView* find_bar_view = GetFindBarView();
187 views::View* next_button = 179 views::View* next_button =
188 find_bar_view->GetViewByID(VIEW_ID_FIND_IN_PAGE_NEXT_BUTTON); 180 find_bar_view->GetViewByID(VIEW_ID_FIND_IN_PAGE_NEXT_BUTTON);
189 views::View* previous_button = 181 views::View* previous_button =
190 find_bar_view->GetViewByID(VIEW_ID_FIND_IN_PAGE_PREVIOUS_BUTTON); 182 find_bar_view->GetViewByID(VIEW_ID_FIND_IN_PAGE_PREVIOUS_BUTTON);
191 183
192 // Clicking the next and previous buttons should not alter the focused view. 184 // Clicking the next and previous buttons should not alter the focused view.
193 ClickOnView(next_button); 185 ClickOnView(next_button);
194 EXPECT_EQ(2, WaitForFinalFindResult().active_match_ordinal()); 186 EXPECT_EQ(2, WaitForFindResult().active_match_ordinal());
195 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); 187 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
196 ClickOnView(previous_button); 188 ClickOnView(previous_button);
197 EXPECT_EQ(1, WaitForFinalFindResult().active_match_ordinal()); 189 EXPECT_EQ(1, WaitForFindResult().active_match_ordinal());
198 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); 190 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
199 191
200 // Tapping the next and previous buttons should not alter the focused view. 192 // Tapping the next and previous buttons should not alter the focused view.
201 TapOnView(next_button); 193 TapOnView(next_button);
202 EXPECT_EQ(2, WaitForFinalFindResult().active_match_ordinal()); 194 EXPECT_EQ(2, WaitForFindResult().active_match_ordinal());
203 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); 195 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
204 TapOnView(previous_button); 196 TapOnView(previous_button);
205 EXPECT_EQ(1, WaitForFinalFindResult().active_match_ordinal()); 197 EXPECT_EQ(1, WaitForFindResult().active_match_ordinal());
206 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); 198 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
207 199
208 // The same should be true even when the previous button is focused. 200 // The same should be true even when the previous button is focused.
209 previous_button->RequestFocus(); 201 previous_button->RequestFocus();
210 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_PREVIOUS_BUTTON)); 202 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_PREVIOUS_BUTTON));
211 ClickOnView(next_button); 203 ClickOnView(next_button);
212 EXPECT_EQ(2, WaitForFinalFindResult().active_match_ordinal()); 204 EXPECT_EQ(2, WaitForFindResult().active_match_ordinal());
213 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_PREVIOUS_BUTTON)); 205 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_PREVIOUS_BUTTON));
214 TapOnView(next_button); 206 TapOnView(next_button);
215 EXPECT_EQ(3, WaitForFinalFindResult().active_match_ordinal()); 207 EXPECT_EQ(3, WaitForFindResult().active_match_ordinal());
216 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_PREVIOUS_BUTTON)); 208 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_PREVIOUS_BUTTON));
217 } 209 }
218 210
219 IN_PROC_BROWSER_TEST_F(FindInPageTest, ButtonsDisabledWithoutText) { 211 IN_PROC_BROWSER_TEST_F(FindInPageTest, ButtonsDisabledWithoutText) {
220 ASSERT_TRUE(embedded_test_server()->Start()); 212 ASSERT_TRUE(embedded_test_server()->Start());
221 // Make sure Chrome is in the foreground, otherwise sending input 213 // Make sure Chrome is in the foreground, otherwise sending input
222 // won't do anything and the test will hang. 214 // won't do anything and the test will hang.
223 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 215 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
224 // First we navigate to any page. 216 // First we navigate to any page.
225 ui_test_utils::NavigateToURL(browser(), 217 ui_test_utils::NavigateToURL(browser(),
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 528
537 ui_test_utils::UrlLoadObserver observer( 529 ui_test_utils::UrlLoadObserver observer(
538 GURL("about:blank"), content::NotificationService::AllSources()); 530 GURL("about:blank"), content::NotificationService::AllSources());
539 531
540 // Send Ctrl-Enter, should cause navigation to about:blank. 532 // Send Ctrl-Enter, should cause navigation to about:blank.
541 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 533 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
542 browser(), ui::VKEY_RETURN, true, false, false, false)); 534 browser(), ui::VKEY_RETURN, true, false, false, false));
543 535
544 observer.Wait(); 536 observer.Wait();
545 } 537 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698