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 "content/public/test/browser_test_utils.h" | 5 #include "content/public/test/browser_test_utils.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <tuple> | 8 #include <tuple> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 #include "content/browser/frame_host/render_frame_host_impl.h" | 34 #include "content/browser/frame_host/render_frame_host_impl.h" |
35 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" | 35 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" |
36 #include "content/browser/renderer_host/render_widget_host_impl.h" | 36 #include "content/browser/renderer_host/render_widget_host_impl.h" |
37 #include "content/browser/web_contents/web_contents_impl.h" | 37 #include "content/browser/web_contents/web_contents_impl.h" |
38 #include "content/browser/web_contents/web_contents_view.h" | 38 #include "content/browser/web_contents/web_contents_view.h" |
39 #include "content/common/input/synthetic_web_input_event_builders.h" | 39 #include "content/common/input/synthetic_web_input_event_builders.h" |
40 #include "content/common/input_messages.h" | 40 #include "content/common/input_messages.h" |
41 #include "content/common/view_messages.h" | 41 #include "content/common/view_messages.h" |
42 #include "content/public/browser/browser_context.h" | 42 #include "content/public/browser/browser_context.h" |
43 #include "content/public/browser/browser_plugin_guest_manager.h" | 43 #include "content/public/browser/browser_plugin_guest_manager.h" |
| 44 #include "content/public/browser/browser_thread.h" |
44 #include "content/public/browser/histogram_fetcher.h" | 45 #include "content/public/browser/histogram_fetcher.h" |
45 #include "content/public/browser/navigation_entry.h" | 46 #include "content/public/browser/navigation_entry.h" |
46 #include "content/public/browser/notification_service.h" | 47 #include "content/public/browser/notification_service.h" |
47 #include "content/public/browser/notification_types.h" | 48 #include "content/public/browser/notification_types.h" |
48 #include "content/public/browser/render_frame_host.h" | 49 #include "content/public/browser/render_frame_host.h" |
49 #include "content/public/browser/render_process_host.h" | 50 #include "content/public/browser/render_process_host.h" |
50 #include "content/public/browser/render_view_host.h" | 51 #include "content/public/browser/render_view_host.h" |
51 #include "content/public/browser/storage_partition.h" | 52 #include "content/public/browser/storage_partition.h" |
52 #include "content/public/browser/web_contents.h" | 53 #include "content/public/browser/web_contents.h" |
53 #include "content/public/test/test_navigation_observer.h" | 54 #include "content/public/test/test_navigation_observer.h" |
54 #include "content/public/test/test_utils.h" | 55 #include "content/public/test/test_utils.h" |
55 #include "content/test/accessibility_browser_test_utils.h" | 56 #include "content/test/accessibility_browser_test_utils.h" |
56 #include "net/base/filename_util.h" | 57 #include "net/base/filename_util.h" |
57 #include "net/cookies/cookie_store.h" | 58 #include "net/cookies/cookie_store.h" |
58 #include "net/test/embedded_test_server/embedded_test_server.h" | 59 #include "net/test/embedded_test_server/embedded_test_server.h" |
59 #include "net/test/embedded_test_server/http_request.h" | 60 #include "net/test/embedded_test_server/http_request.h" |
60 #include "net/test/embedded_test_server/http_response.h" | 61 #include "net/test/embedded_test_server/http_response.h" |
61 #include "net/test/python_utils.h" | 62 #include "net/test/python_utils.h" |
62 #include "net/url_request/url_request_context.h" | 63 #include "net/url_request/url_request_context.h" |
63 #include "net/url_request/url_request_context_getter.h" | 64 #include "net/url_request/url_request_context_getter.h" |
64 #include "testing/gtest/include/gtest/gtest.h" | 65 #include "testing/gtest/include/gtest/gtest.h" |
| 66 #include "ui/base/clipboard/clipboard.h" |
| 67 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
65 #include "ui/base/resource/resource_bundle.h" | 68 #include "ui/base/resource/resource_bundle.h" |
| 69 #include "ui/base/test/test_clipboard.h" |
66 #include "ui/compositor/test/draw_waiter_for_test.h" | 70 #include "ui/compositor/test/draw_waiter_for_test.h" |
67 #include "ui/events/gesture_detection/gesture_configuration.h" | 71 #include "ui/events/gesture_detection/gesture_configuration.h" |
68 #include "ui/events/keycodes/dom/dom_code.h" | 72 #include "ui/events/keycodes/dom/dom_code.h" |
69 #include "ui/events/keycodes/dom/keycode_converter.h" | 73 #include "ui/events/keycodes/dom/keycode_converter.h" |
70 #include "ui/events/latency_info.h" | 74 #include "ui/events/latency_info.h" |
71 #include "ui/resources/grit/webui_resources.h" | 75 #include "ui/resources/grit/webui_resources.h" |
72 | 76 |
73 #if defined(USE_AURA) | 77 #if defined(USE_AURA) |
74 #include "content/browser/renderer_host/render_widget_host_view_aura.h" | 78 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
75 #include "ui/aura/test/window_event_dispatcher_test_api.h" | 79 #include "ui/aura/test/window_event_dispatcher_test_api.h" |
(...skipping 1348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1424 uint32_t InputMsgWatcher::WaitForAck() { | 1428 uint32_t InputMsgWatcher::WaitForAck() { |
1425 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1429 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1426 if (ack_result_ != INPUT_EVENT_ACK_STATE_UNKNOWN) | 1430 if (ack_result_ != INPUT_EVENT_ACK_STATE_UNKNOWN) |
1427 return ack_result_; | 1431 return ack_result_; |
1428 base::RunLoop run_loop; | 1432 base::RunLoop run_loop; |
1429 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure()); | 1433 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure()); |
1430 run_loop.Run(); | 1434 run_loop.Run(); |
1431 return ack_result_; | 1435 return ack_result_; |
1432 } | 1436 } |
1433 | 1437 |
| 1438 #if defined(OS_WIN) |
| 1439 static void RunTaskAndSignalCompletion(const base::Closure& task, |
| 1440 base::WaitableEvent* completion) { |
| 1441 task.Run(); |
| 1442 completion->Signal(); |
| 1443 } |
| 1444 |
| 1445 static void RunTaskOnIOThreadAndWait(const base::Closure& task) { |
| 1446 base::WaitableEvent completion( |
| 1447 base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 1448 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 1449 BrowserThread::PostTask( |
| 1450 BrowserThread::IO, FROM_HERE, |
| 1451 base::Bind(&RunTaskAndSignalCompletion, task, &completion)); |
| 1452 completion.Wait(); |
| 1453 } |
| 1454 #endif |
| 1455 |
| 1456 static void SetUpTestClipboard() { |
| 1457 #if defined(OS_WIN) |
| 1458 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
| 1459 RunTaskOnIOThreadAndWait(base::Bind(&SetUpTestClipboard)); |
| 1460 return; |
| 1461 } |
| 1462 #endif |
| 1463 ui::TestClipboard::CreateForCurrentThread(); |
| 1464 } |
| 1465 |
| 1466 // TODO(dcheng): Make the test clipboard on different threads share the |
| 1467 // same backing store. crbug.com/629765 |
| 1468 BrowserTestClipboardScope::BrowserTestClipboardScope() { |
| 1469 SetUpTestClipboard(); |
| 1470 } |
| 1471 |
| 1472 static void TearDownTestClipboard() { |
| 1473 #if defined(OS_WIN) |
| 1474 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
| 1475 RunTaskOnIOThreadAndWait(base::Bind(&TearDownTestClipboard)); |
| 1476 return; |
| 1477 } |
| 1478 #endif |
| 1479 ui::Clipboard::DestroyClipboardForCurrentThread(); |
| 1480 } |
| 1481 |
| 1482 BrowserTestClipboardScope::~BrowserTestClipboardScope() { |
| 1483 TearDownTestClipboard(); |
| 1484 } |
| 1485 |
| 1486 void BrowserTestClipboardScope::SetRtf(const std::string& rtf) { |
| 1487 #if defined(OS_WIN) |
| 1488 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
| 1489 RunTaskOnIOThreadAndWait(base::Bind(&BrowserTestClipboardScope::SetRtf, |
| 1490 base::Unretained(this), rtf)); |
| 1491 return; |
| 1492 } |
| 1493 #endif |
| 1494 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_COPY_PASTE); |
| 1495 clipboard_writer.WriteRTF(rtf); |
| 1496 } |
| 1497 |
| 1498 void BrowserTestClipboardScope::SetText(const std::string& text) { |
| 1499 #if defined(OS_WIN) |
| 1500 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
| 1501 RunTaskOnIOThreadAndWait(base::Bind(&BrowserTestClipboardScope::SetText, |
| 1502 base::Unretained(this), text)); |
| 1503 return; |
| 1504 } |
| 1505 #endif |
| 1506 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_COPY_PASTE); |
| 1507 clipboard_writer.WriteText(base::ASCIIToUTF16(text)); |
| 1508 } |
| 1509 |
1434 } // namespace content | 1510 } // namespace content |
OLD | NEW |