OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/shell/renderer/test_runner/test_runner.h" | 5 #include "content/shell/renderer/test_runner/test_runner.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "content/shell/common/test_runner/test_preferences.h" | 10 #include "content/shell/common/test_runner/test_preferences.h" |
11 #include "content/shell/renderer/test_runner/MockWebSpeechRecognizer.h" | 11 #include "content/shell/renderer/test_runner/MockWebSpeechRecognizer.h" |
12 #include "content/shell/renderer/test_runner/TestInterfaces.h" | 12 #include "content/shell/renderer/test_runner/TestInterfaces.h" |
13 #include "content/shell/renderer/test_runner/WebPermissions.h" | 13 #include "content/shell/renderer/test_runner/WebPermissions.h" |
14 #include "content/shell/renderer/test_runner/WebTestDelegate.h" | 14 #include "content/shell/renderer/test_runner/WebTestDelegate.h" |
15 #include "content/shell/renderer/test_runner/WebTestProxy.h" | |
16 #include "content/shell/renderer/test_runner/notification_presenter.h" | 15 #include "content/shell/renderer/test_runner/notification_presenter.h" |
| 16 #include "content/shell/renderer/test_runner/web_test_proxy.h" |
17 #include "gin/arguments.h" | 17 #include "gin/arguments.h" |
18 #include "gin/array_buffer.h" | 18 #include "gin/array_buffer.h" |
19 #include "gin/handle.h" | 19 #include "gin/handle.h" |
20 #include "gin/object_template_builder.h" | 20 #include "gin/object_template_builder.h" |
21 #include "gin/wrappable.h" | 21 #include "gin/wrappable.h" |
22 #include "third_party/WebKit/public/platform/WebCanvas.h" | 22 #include "third_party/WebKit/public/platform/WebCanvas.h" |
23 #include "third_party/WebKit/public/platform/WebData.h" | 23 #include "third_party/WebKit/public/platform/WebData.h" |
24 #include "third_party/WebKit/public/platform/WebDeviceMotionData.h" | 24 #include "third_party/WebKit/public/platform/WebDeviceMotionData.h" |
25 #include "third_party/WebKit/public/platform/WebDeviceOrientationData.h" | 25 #include "third_party/WebKit/public/platform/WebDeviceOrientationData.h" |
26 #include "third_party/WebKit/public/platform/WebPoint.h" | 26 #include "third_party/WebKit/public/platform/WebPoint.h" |
(...skipping 1723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1750 | 1750 |
1751 private: | 1751 private: |
1752 int distance_; | 1752 int distance_; |
1753 }; | 1753 }; |
1754 | 1754 |
1755 void TestRunner::NotifyDone() { | 1755 void TestRunner::NotifyDone() { |
1756 if (disable_notify_done_) | 1756 if (disable_notify_done_) |
1757 return; | 1757 return; |
1758 | 1758 |
1759 // Test didn't timeout. Kill the timeout timer. | 1759 // Test didn't timeout. Kill the timeout timer. |
1760 taskList()->revokeAll(); | 1760 task_list_.revokeAll(); |
1761 | 1761 |
1762 CompleteNotifyDone(); | 1762 CompleteNotifyDone(); |
1763 } | 1763 } |
1764 | 1764 |
1765 void TestRunner::WaitUntilDone() { | 1765 void TestRunner::WaitUntilDone() { |
1766 wait_until_done_ = true; | 1766 wait_until_done_ = true; |
1767 } | 1767 } |
1768 | 1768 |
1769 void TestRunner::QueueBackNavigation(int how_far_back) { | 1769 void TestRunner::QueueBackNavigation(int how_far_back) { |
1770 work_queue_.AddWork(new WorkItemBackForward(-how_far_back)); | 1770 work_queue_.AddWork(new WorkItemBackForward(-how_far_back)); |
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2465 | 2465 |
2466 void TestRunner::WaitUntilExternalURLLoad() { | 2466 void TestRunner::WaitUntilExternalURLLoad() { |
2467 wait_until_external_url_load_ = true; | 2467 wait_until_external_url_load_ = true; |
2468 } | 2468 } |
2469 | 2469 |
2470 void TestRunner::CloseWebInspector() { | 2470 void TestRunner::CloseWebInspector() { |
2471 delegate_->closeDevTools(); | 2471 delegate_->closeDevTools(); |
2472 } | 2472 } |
2473 | 2473 |
2474 bool TestRunner::IsChooserShown() { | 2474 bool TestRunner::IsChooserShown() { |
2475 return proxy_->isChooserShown(); | 2475 return proxy_->IsChooserShown(); |
2476 } | 2476 } |
2477 | 2477 |
2478 void TestRunner::EvaluateInWebInspector(int call_id, | 2478 void TestRunner::EvaluateInWebInspector(int call_id, |
2479 const std::string& script) { | 2479 const std::string& script) { |
2480 delegate_->evaluateInWebInspector(call_id, script); | 2480 delegate_->evaluateInWebInspector(call_id, script); |
2481 } | 2481 } |
2482 | 2482 |
2483 void TestRunner::ClearAllDatabases() { | 2483 void TestRunner::ClearAllDatabases() { |
2484 delegate_->clearAllDatabases(); | 2484 delegate_->clearAllDatabases(); |
2485 } | 2485 } |
(...skipping 10 matching lines...) Expand all Loading... |
2496 delegate_->setFocus(proxy_, value); | 2496 delegate_->setFocus(proxy_, value); |
2497 } | 2497 } |
2498 | 2498 |
2499 std::string TestRunner::PathToLocalResource(const std::string& path) { | 2499 std::string TestRunner::PathToLocalResource(const std::string& path) { |
2500 return delegate_->pathToLocalResource(path); | 2500 return delegate_->pathToLocalResource(path); |
2501 } | 2501 } |
2502 | 2502 |
2503 void TestRunner::SetBackingScaleFactor(double value, | 2503 void TestRunner::SetBackingScaleFactor(double value, |
2504 v8::Handle<v8::Function> callback) { | 2504 v8::Handle<v8::Function> callback) { |
2505 delegate_->setDeviceScaleFactor(value); | 2505 delegate_->setDeviceScaleFactor(value); |
2506 proxy_->discardBackingStore(); | 2506 proxy_->DiscardBackingStore(); |
2507 delegate_->postTask(new InvokeCallbackTask(this, callback)); | 2507 delegate_->postTask(new InvokeCallbackTask(this, callback)); |
2508 } | 2508 } |
2509 | 2509 |
2510 void TestRunner::SetColorProfile(const std::string& name, | 2510 void TestRunner::SetColorProfile(const std::string& name, |
2511 v8::Handle<v8::Function> callback) { | 2511 v8::Handle<v8::Function> callback) { |
2512 delegate_->setDeviceColorProfile(name); | 2512 delegate_->setDeviceColorProfile(name); |
2513 delegate_->postTask(new InvokeCallbackTask(this, callback)); | 2513 delegate_->postTask(new InvokeCallbackTask(this, callback)); |
2514 } | 2514 } |
2515 | 2515 |
2516 void TestRunner::SetPOSIXLocale(const std::string& locale) { | 2516 void TestRunner::SetPOSIXLocale(const std::string& locale) { |
2517 delegate_->setLocale(locale); | 2517 delegate_->setLocale(locale); |
2518 } | 2518 } |
2519 | 2519 |
2520 void TestRunner::SetMIDIAccessorResult(bool result) { | 2520 void TestRunner::SetMIDIAccessorResult(bool result) { |
2521 midi_accessor_result_ = result; | 2521 midi_accessor_result_ = result; |
2522 } | 2522 } |
2523 | 2523 |
2524 void TestRunner::SetMIDISysexPermission(bool value) { | 2524 void TestRunner::SetMIDISysexPermission(bool value) { |
2525 const std::vector<WebTestProxyBase*>& windowList = | 2525 const std::vector<WebTestProxyBase*>& windowList = |
2526 test_interfaces_->windowList(); | 2526 test_interfaces_->windowList(); |
2527 for (unsigned i = 0; i < windowList.size(); ++i) | 2527 for (unsigned i = 0; i < windowList.size(); ++i) |
2528 windowList.at(i)->midiClientMock()->setSysexPermission(value); | 2528 windowList.at(i)->GetMIDIClientMock()->setSysexPermission(value); |
2529 } | 2529 } |
2530 | 2530 |
2531 void TestRunner::GrantWebNotificationPermission(const std::string& origin, | 2531 void TestRunner::GrantWebNotificationPermission(const std::string& origin, |
2532 bool permission_granted) { | 2532 bool permission_granted) { |
2533 notification_presenter_->GrantPermission(origin, permission_granted); | 2533 notification_presenter_->GrantPermission(origin, permission_granted); |
2534 } | 2534 } |
2535 | 2535 |
2536 bool TestRunner::SimulateWebNotificationClick(const std::string& value) { | 2536 bool TestRunner::SimulateWebNotificationClick(const std::string& value) { |
2537 return notification_presenter_->SimulateClick(value); | 2537 return notification_presenter_->SimulateClick(value); |
2538 } | 2538 } |
2539 | 2539 |
2540 void TestRunner::AddMockSpeechRecognitionResult(const std::string& transcript, | 2540 void TestRunner::AddMockSpeechRecognitionResult(const std::string& transcript, |
2541 double confidence) { | 2541 double confidence) { |
2542 proxy_->speechRecognizerMock()->addMockResult( | 2542 proxy_->GetSpeechRecognizerMock()->addMockResult( |
2543 WebString::fromUTF8(transcript), confidence); | 2543 WebString::fromUTF8(transcript), confidence); |
2544 } | 2544 } |
2545 | 2545 |
2546 void TestRunner::SetMockSpeechRecognitionError(const std::string& error, | 2546 void TestRunner::SetMockSpeechRecognitionError(const std::string& error, |
2547 const std::string& message) { | 2547 const std::string& message) { |
2548 proxy_->speechRecognizerMock()->setError(WebString::fromUTF8(error), | 2548 proxy_->GetSpeechRecognizerMock()->setError(WebString::fromUTF8(error), |
2549 WebString::fromUTF8(message)); | 2549 WebString::fromUTF8(message)); |
2550 } | 2550 } |
2551 | 2551 |
2552 bool TestRunner::WasMockSpeechRecognitionAborted() { | 2552 bool TestRunner::WasMockSpeechRecognitionAborted() { |
2553 return proxy_->speechRecognizerMock()->wasAborted(); | 2553 return proxy_->GetSpeechRecognizerMock()->wasAborted(); |
2554 } | 2554 } |
2555 | 2555 |
2556 void TestRunner::AddWebPageOverlay() { | 2556 void TestRunner::AddWebPageOverlay() { |
2557 if (web_view_ && !page_overlay_) { | 2557 if (web_view_ && !page_overlay_) { |
2558 page_overlay_ = new TestPageOverlay(web_view_); | 2558 page_overlay_ = new TestPageOverlay(web_view_); |
2559 web_view_->addPageOverlay(page_overlay_, 0); | 2559 web_view_->addPageOverlay(page_overlay_, 0); |
2560 } | 2560 } |
2561 } | 2561 } |
2562 | 2562 |
2563 void TestRunner::RemoveWebPageOverlay() { | 2563 void TestRunner::RemoveWebPageOverlay() { |
2564 if (web_view_ && page_overlay_) { | 2564 if (web_view_ && page_overlay_) { |
2565 web_view_->removePageOverlay(page_overlay_); | 2565 web_view_->removePageOverlay(page_overlay_); |
2566 delete page_overlay_; | 2566 delete page_overlay_; |
2567 page_overlay_ = NULL; | 2567 page_overlay_ = NULL; |
2568 } | 2568 } |
2569 } | 2569 } |
2570 | 2570 |
2571 void TestRunner::DisplayAsync() { | 2571 void TestRunner::DisplayAsync() { |
2572 proxy_->displayAsyncThen(base::Closure()); | 2572 proxy_->DisplayAsyncThen(base::Closure()); |
2573 } | 2573 } |
2574 | 2574 |
2575 void TestRunner::DisplayAsyncThen(v8::Handle<v8::Function> callback) { | 2575 void TestRunner::DisplayAsyncThen(v8::Handle<v8::Function> callback) { |
2576 scoped_ptr<InvokeCallbackTask> task( | 2576 scoped_ptr<InvokeCallbackTask> task( |
2577 new InvokeCallbackTask(this, callback)); | 2577 new InvokeCallbackTask(this, callback)); |
2578 proxy_->displayAsyncThen(base::Bind(&TestRunner::InvokeCallback, | 2578 proxy_->DisplayAsyncThen(base::Bind(&TestRunner::InvokeCallback, |
2579 base::Unretained(this), | 2579 base::Unretained(this), |
2580 base::Passed(&task))); | 2580 base::Passed(&task))); |
2581 } | 2581 } |
2582 | 2582 |
2583 void TestRunner::LocationChangeDone() { | 2583 void TestRunner::LocationChangeDone() { |
2584 web_history_item_count_ = delegate_->navigationEntryCount(); | 2584 web_history_item_count_ = delegate_->navigationEntryCount(); |
2585 | 2585 |
2586 // No more new work after the first complete load. | 2586 // No more new work after the first complete load. |
2587 work_queue_.set_frozen(true); | 2587 work_queue_.set_frozen(true); |
2588 | 2588 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2627 } | 2627 } |
2628 | 2628 |
2629 void TestRunner::DidLosePointerLockInternal() { | 2629 void TestRunner::DidLosePointerLockInternal() { |
2630 bool was_locked = pointer_locked_; | 2630 bool was_locked = pointer_locked_; |
2631 pointer_locked_ = false; | 2631 pointer_locked_ = false; |
2632 if (was_locked) | 2632 if (was_locked) |
2633 web_view_->didLosePointerLock(); | 2633 web_view_->didLosePointerLock(); |
2634 } | 2634 } |
2635 | 2635 |
2636 } // namespace content | 2636 } // namespace content |
OLD | NEW |