| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/process_util.h" | 5 #include "base/process_util.h" |
| 6 #include "base/string_util.h" | 6 #include "base/string_util.h" |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/tabs/tab_strip_model.h" | 8 #include "chrome/browser/tabs/tab_strip_model.h" |
| 9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 10 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
| 11 #include "chrome/browser/ui/find_bar/find_notification_details.h" | 11 #include "chrome/browser/ui/find_bar/find_notification_details.h" |
| 12 #include "chrome/browser/ui/view_ids.h" | 12 #include "chrome/browser/ui/view_ids.h" |
| 13 #include "chrome/browser/ui/views/find_bar_host.h" | 13 #include "chrome/browser/ui/views/find_bar_host.h" |
| 14 #include "chrome/browser/ui/views/frame/browser_view.h" | 14 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 15 #include "chrome/common/chrome_notification_types.h" | 15 #include "chrome/common/chrome_notification_types.h" |
| 16 #include "chrome/test/base/in_process_browser_test.h" | 16 #include "chrome/test/base/in_process_browser_test.h" |
| 17 #include "chrome/test/base/ui_test_utils.h" | 17 #include "chrome/test/base/ui_test_utils.h" |
| 18 #include "content/browser/tab_contents/tab_contents.h" | 18 #include "content/browser/tab_contents/tab_contents.h" |
| 19 #include "content/public/browser/notification_service.h" | 19 #include "content/public/browser/notification_service.h" |
| 20 #include "net/test/test_server.h" | 20 #include "net/test/test_server.h" |
| 21 #include "ui/base/clipboard/clipboard.h" | 21 #include "ui/base/clipboard/clipboard.h" |
| 22 #include "ui/base/keycodes/keyboard_codes.h" | 22 #include "ui/base/keycodes/keyboard_codes.h" |
| 23 #include "ui/views/focus/focus_manager.h" | 23 #include "ui/views/focus/focus_manager.h" |
| 24 #include "ui/views/view.h" | 24 #include "ui/views/view.h" |
| 25 #include "ui/views/views_delegate.h" | 25 #include "ui/views/views_delegate.h" |
| 26 | 26 |
| 27 using content::WebContents; |
| 28 |
| 27 namespace { | 29 namespace { |
| 28 | 30 |
| 29 // The delay waited after sending an OS simulated event. | 31 // The delay waited after sending an OS simulated event. |
| 30 static const int kActionDelayMs = 500; | 32 static const int kActionDelayMs = 500; |
| 31 static const char kSimplePage[] = "files/find_in_page/simple.html"; | 33 static const char kSimplePage[] = "files/find_in_page/simple.html"; |
| 32 | 34 |
| 33 void Checkpoint(const char* message, const base::TimeTicks& start_time) { | 35 void Checkpoint(const char* message, const base::TimeTicks& start_time) { |
| 34 LOG(INFO) << message << " : " | 36 LOG(INFO) << message << " : " |
| 35 << (base::TimeTicks::Now() - start_time).InMilliseconds() | 37 << (base::TimeTicks::Now() - start_time).InMilliseconds() |
| 36 << " ms" << std::flush; | 38 << " ms" << std::flush; |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 | 345 |
| 344 string16 str; | 346 string16 str; |
| 345 views::ViewsDelegate::views_delegate->GetClipboard()-> | 347 views::ViewsDelegate::views_delegate->GetClipboard()-> |
| 346 ReadText(ui::Clipboard::BUFFER_STANDARD, &str); | 348 ReadText(ui::Clipboard::BUFFER_STANDARD, &str); |
| 347 | 349 |
| 348 // Make sure the text is copied successfully. | 350 // Make sure the text is copied successfully. |
| 349 EXPECT_EQ(ASCIIToUTF16("a"), str); | 351 EXPECT_EQ(ASCIIToUTF16("a"), str); |
| 350 | 352 |
| 351 // Press Ctrl-V to paste the content back, it should start finding even if the | 353 // Press Ctrl-V to paste the content back, it should start finding even if the |
| 352 // content is not changed. | 354 // content is not changed. |
| 353 content::Source<TabContents> notification_source( | 355 content::Source<WebContents> notification_source( |
| 354 browser()->GetSelectedTabContents()); | 356 browser()->GetSelectedTabContents()); |
| 355 ui_test_utils::WindowedNotificationObserverWithDetails | 357 ui_test_utils::WindowedNotificationObserverWithDetails |
| 356 <FindNotificationDetails> observer( | 358 <FindNotificationDetails> observer( |
| 357 chrome::NOTIFICATION_FIND_RESULT_AVAILABLE, notification_source); | 359 chrome::NOTIFICATION_FIND_RESULT_AVAILABLE, notification_source); |
| 358 | 360 |
| 359 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 361 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
| 360 browser(), ui::VKEY_V, true, false, false, false)); | 362 browser(), ui::VKEY_V, true, false, false, false)); |
| 361 | 363 |
| 362 ASSERT_NO_FATAL_FAILURE(observer.Wait()); | 364 ASSERT_NO_FATAL_FAILURE(observer.Wait()); |
| 363 FindNotificationDetails details; | 365 FindNotificationDetails details; |
| 364 ASSERT_TRUE(observer.GetDetailsFor(notification_source.map_key(), &details)); | 366 ASSERT_TRUE(observer.GetDetailsFor(notification_source.map_key(), &details)); |
| 365 EXPECT_TRUE(details.number_of_matches() > 0); | 367 EXPECT_TRUE(details.number_of_matches() > 0); |
| 366 } | 368 } |
| OLD | NEW |