OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/test/ui_test_utils.h" | 5 #include "chrome/test/ui_test_utils.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
11 #include "base/json/json_reader.h" | 11 #include "base/json/json_reader.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
14 #include "base/process_util.h" | 14 #include "base/process_util.h" |
15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "chrome/browser/automation/ui_controls.h" | |
17 #include "chrome/browser/browser.h" | 18 #include "chrome/browser/browser.h" |
18 #include "chrome/browser/browser_list.h" | 19 #include "chrome/browser/browser_list.h" |
19 #include "chrome/browser/dom_operation_notification_details.h" | 20 #include "chrome/browser/dom_operation_notification_details.h" |
20 #include "chrome/browser/download/download_item.h" | 21 #include "chrome/browser/download/download_item.h" |
21 #include "chrome/browser/download/download_manager.h" | 22 #include "chrome/browser/download/download_manager.h" |
22 #include "chrome/browser/profile.h" | 23 #include "chrome/browser/profile.h" |
23 #include "chrome/browser/renderer_host/render_process_host.h" | 24 #include "chrome/browser/renderer_host/render_process_host.h" |
24 #include "chrome/browser/renderer_host/render_view_host.h" | 25 #include "chrome/browser/renderer_host/render_view_host.h" |
25 #include "chrome/browser/tab_contents/navigation_controller.h" | 26 #include "chrome/browser/tab_contents/navigation_controller.h" |
26 #include "chrome/browser/tab_contents/navigation_entry.h" | 27 #include "chrome/browser/tab_contents/navigation_entry.h" |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
542 void WaitForBookmarkModelToLoad(BookmarkModel* model) { | 543 void WaitForBookmarkModelToLoad(BookmarkModel* model) { |
543 if (model->IsLoaded()) | 544 if (model->IsLoaded()) |
544 return; | 545 return; |
545 BookmarkLoadObserver observer; | 546 BookmarkLoadObserver observer; |
546 model->AddObserver(&observer); | 547 model->AddObserver(&observer); |
547 RunMessageLoop(); | 548 RunMessageLoop(); |
548 model->RemoveObserver(&observer); | 549 model->RemoveObserver(&observer); |
549 ASSERT_TRUE(model->IsLoaded()); | 550 ASSERT_TRUE(model->IsLoaded()); |
550 } | 551 } |
551 | 552 |
553 bool SendKeyPressSync(gfx::NativeWindow window, | |
554 base::KeyboardCode key, | |
555 bool control, | |
556 bool shift, | |
557 bool alt, | |
558 bool command) { | |
559 if (!ui_controls::SendKeyPressNotifyWhenDone( | |
560 window, key, control, shift, alt, command, | |
561 new MessageLoop::QuitTask())) { | |
562 DLOG(ERROR) << "ui_controls::SendKeyPressNotifyWhenDone failed"; | |
Paweł Hajdan Jr.
2010/08/21 02:44:28
nit: You can consider using LOG instead of DLOG he
| |
563 return false; | |
564 } | |
565 // Run the message loop, it'll quit because either the key was received or the | |
Paweł Hajdan Jr.
2010/08/21 02:44:28
nit: I think this comment is confusing. I'd rather
| |
566 // test timed out. | |
567 RunMessageLoop(); | |
568 return !testing::Test::HasFatalFailure(); | |
569 } | |
570 | |
552 TimedMessageLoopRunner::TimedMessageLoopRunner() | 571 TimedMessageLoopRunner::TimedMessageLoopRunner() |
553 : loop_(new MessageLoopForUI()), | 572 : loop_(new MessageLoopForUI()), |
554 owned_(true), | 573 owned_(true), |
555 quit_loop_invoked_(false) { | 574 quit_loop_invoked_(false) { |
556 } | 575 } |
557 | 576 |
558 TimedMessageLoopRunner::~TimedMessageLoopRunner() { | 577 TimedMessageLoopRunner::~TimedMessageLoopRunner() { |
559 if (owned_) | 578 if (owned_) |
560 delete loop_; | 579 delete loop_; |
561 } | 580 } |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
655 | 674 |
656 TestWebSocketServer::~TestWebSocketServer() { | 675 TestWebSocketServer::~TestWebSocketServer() { |
657 scoped_ptr<CommandLine> cmd_line(CreateWebSocketServerCommandLine()); | 676 scoped_ptr<CommandLine> cmd_line(CreateWebSocketServerCommandLine()); |
658 cmd_line->AppendSwitchASCII("server", "stop"); | 677 cmd_line->AppendSwitchASCII("server", "stop"); |
659 cmd_line->AppendSwitch("chromium"); | 678 cmd_line->AppendSwitch("chromium"); |
660 cmd_line->AppendSwitchPath("pidfile", websocket_pid_file_); | 679 cmd_line->AppendSwitchPath("pidfile", websocket_pid_file_); |
661 base::LaunchApp(*cmd_line.get(), true, false, NULL); | 680 base::LaunchApp(*cmd_line.get(), true, false, NULL); |
662 } | 681 } |
663 | 682 |
664 } // namespace ui_test_utils | 683 } // namespace ui_test_utils |
OLD | NEW |