OLD | NEW |
---|---|
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 <stdio.h> | 5 #include <stdio.h> |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/string16.h" | 8 #include "base/string16.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
218 type, source); | 218 type, source); |
219 } | 219 } |
220 | 220 |
221 void WaitForTabOpenOrCloseForBrowser(const Browser* browser, | 221 void WaitForTabOpenOrCloseForBrowser(const Browser* browser, |
222 int expected_tab_count) { | 222 int expected_tab_count) { |
223 int tab_count = browser->tab_count(); | 223 int tab_count = browser->tab_count(); |
224 if (tab_count == expected_tab_count) | 224 if (tab_count == expected_tab_count) |
225 return; | 225 return; |
226 | 226 |
227 content::NotificationRegistrar registrar; | 227 content::NotificationRegistrar registrar; |
228 registrar.Add(this, | 228 registrar.Add( |
229 (tab_count < expected_tab_count ? | 229 this, |
230 content::NOTIFICATION_TAB_PARENTED : | 230 tab_count < expected_tab_count |
231 content::NOTIFICATION_TAB_CLOSED), | 231 ? static_cast<int>(chrome::NOTIFICATION_TAB_PARENTED) |
jam
2012/04/15 22:10:18
nit: you shouldn't need a cast here?
Avi (use Gerrit)
2012/04/16 00:09:39
It wouldn't be there if I didn't need it :) chrome
| |
232 content::NotificationService::AllSources()); | 232 : static_cast<int>(content::NOTIFICATION_WEB_CONTENTS_DESTROYED), |
233 content::NotificationService::AllSources()); | |
233 | 234 |
234 while (!HasFailure() && browser->tab_count() != expected_tab_count) | 235 while (!HasFailure() && browser->tab_count() != expected_tab_count) |
235 ui_test_utils::RunMessageLoop(); | 236 ui_test_utils::RunMessageLoop(); |
236 | 237 |
237 ASSERT_EQ(expected_tab_count, browser->tab_count()); | 238 ASSERT_EQ(expected_tab_count, browser->tab_count()); |
238 } | 239 } |
239 | 240 |
240 void WaitForTabOpenOrClose(int expected_tab_count) { | 241 void WaitForTabOpenOrClose(int expected_tab_count) { |
241 WaitForTabOpenOrCloseForBrowser(browser(), expected_tab_count); | 242 WaitForTabOpenOrCloseForBrowser(browser(), expected_tab_count); |
242 } | 243 } |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
364 void SetupComponents() { | 365 void SetupComponents() { |
365 ASSERT_NO_FATAL_FAILURE(SetupHostResolver()); | 366 ASSERT_NO_FATAL_FAILURE(SetupHostResolver()); |
366 ASSERT_NO_FATAL_FAILURE(SetupSearchEngine()); | 367 ASSERT_NO_FATAL_FAILURE(SetupSearchEngine()); |
367 ASSERT_NO_FATAL_FAILURE(SetupHistory()); | 368 ASSERT_NO_FATAL_FAILURE(SetupHistory()); |
368 } | 369 } |
369 | 370 |
370 virtual void Observe(int type, | 371 virtual void Observe(int type, |
371 const content::NotificationSource& source, | 372 const content::NotificationSource& source, |
372 const content::NotificationDetails& details) { | 373 const content::NotificationDetails& details) { |
373 switch (type) { | 374 switch (type) { |
374 case content::NOTIFICATION_TAB_CLOSED: | 375 case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: |
375 case content::NOTIFICATION_TAB_PARENTED: | 376 case chrome::NOTIFICATION_TAB_PARENTED: |
376 case chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY: | 377 case chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY: |
377 case chrome::NOTIFICATION_BOOKMARK_MODEL_LOADED: | 378 case chrome::NOTIFICATION_BOOKMARK_MODEL_LOADED: |
378 case chrome::NOTIFICATION_HISTORY_LOADED: | 379 case chrome::NOTIFICATION_HISTORY_LOADED: |
379 case chrome::NOTIFICATION_HISTORY_URLS_MODIFIED: | 380 case chrome::NOTIFICATION_HISTORY_URLS_MODIFIED: |
380 case chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED: | 381 case chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED: |
381 break; | 382 break; |
382 default: | 383 default: |
383 FAIL() << "Unexpected notification type"; | 384 FAIL() << "Unexpected notification type"; |
384 } | 385 } |
385 MessageLoop::current()->Quit(); | 386 MessageLoop::current()->Quit(); |
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1474 | 1475 |
1475 // Paste text. | 1476 // Paste text. |
1476 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_V, ui::EF_CONTROL_DOWN)); | 1477 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_V, ui::EF_CONTROL_DOWN)); |
1477 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); | 1478 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
1478 ASSERT_TRUE(popup_model->IsOpen()); | 1479 ASSERT_TRUE(popup_model->IsOpen()); |
1479 | 1480 |
1480 // Inline autocomplete shouldn't be triggered. | 1481 // Inline autocomplete shouldn't be triggered. |
1481 ASSERT_EQ(ASCIIToUTF16("abc"), omnibox_view->GetText()); | 1482 ASSERT_EQ(ASCIIToUTF16("abc"), omnibox_view->GetText()); |
1482 } | 1483 } |
1483 #endif | 1484 #endif |
OLD | NEW |