| 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 #ifndef CONTENT_SHELL_RENDERER_TEST_RUNNER_TEST_RUNNER_H_ | 5 #ifndef CONTENT_SHELL_RENDERER_TEST_RUNNER_TEST_RUNNER_H_ |
| 6 #define CONTENT_SHELL_RENDERER_TEST_RUNNER_TEST_RUNNER_H_ | 6 #define CONTENT_SHELL_RENDERER_TEST_RUNNER_TEST_RUNNER_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 class WebPermissionClient; | 21 class WebPermissionClient; |
| 22 class WebString; | 22 class WebString; |
| 23 class WebView; | 23 class WebView; |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace gin { | 26 namespace gin { |
| 27 class ArrayBufferView; | 27 class ArrayBufferView; |
| 28 class Arguments; | 28 class Arguments; |
| 29 } | 29 } |
| 30 | 30 |
| 31 namespace WebTestRunner { | |
| 32 class TestInterfaces; | |
| 33 class WebTestDelegate; | |
| 34 } | |
| 35 | |
| 36 namespace content { | 31 namespace content { |
| 37 | 32 |
| 38 class InvokeCallbackTask; | 33 class InvokeCallbackTask; |
| 39 class NotificationPresenter; | 34 class NotificationPresenter; |
| 35 class TestInterfaces; |
| 40 class TestPageOverlay; | 36 class TestPageOverlay; |
| 41 class WebPermissions; | 37 class WebPermissions; |
| 38 class WebTestDelegate; |
| 42 class WebTestProxyBase; | 39 class WebTestProxyBase; |
| 43 | 40 |
| 44 class TestRunner : public ::WebTestRunner::WebTestRunner, | 41 class TestRunner : public WebTestRunner, |
| 45 public base::SupportsWeakPtr<TestRunner> { | 42 public base::SupportsWeakPtr<TestRunner> { |
| 46 public: | 43 public: |
| 47 explicit TestRunner(::WebTestRunner::TestInterfaces*); | 44 explicit TestRunner(TestInterfaces*); |
| 48 virtual ~TestRunner(); | 45 virtual ~TestRunner(); |
| 49 | 46 |
| 50 void Install(blink::WebFrame* frame); | 47 void Install(blink::WebFrame* frame); |
| 51 | 48 |
| 52 void SetDelegate(::WebTestRunner::WebTestDelegate*); | 49 void SetDelegate(WebTestDelegate*); |
| 53 void SetWebView(blink::WebView*, WebTestProxyBase*); | 50 void SetWebView(blink::WebView*, WebTestProxyBase*); |
| 54 | 51 |
| 55 void Reset(); | 52 void Reset(); |
| 56 | 53 |
| 57 ::WebTestRunner::WebTaskList* taskList() { return &task_list_; } | 54 WebTaskList* taskList() { return &task_list_; } |
| 58 | 55 |
| 59 void SetTestIsRunning(bool); | 56 void SetTestIsRunning(bool); |
| 60 bool TestIsRunning() const { return test_is_running_; } | 57 bool TestIsRunning() const { return test_is_running_; } |
| 61 | 58 |
| 62 bool UseMockTheme() const { return use_mock_theme_; } | 59 bool UseMockTheme() const { return use_mock_theme_; } |
| 63 | 60 |
| 64 void InvokeCallback(scoped_ptr<InvokeCallbackTask> callback); | 61 void InvokeCallback(scoped_ptr<InvokeCallbackTask> callback); |
| 65 | 62 |
| 66 // WebTestRunner implementation. | 63 // WebTestRunner implementation. |
| 67 virtual bool shouldGeneratePixelResults() OVERRIDE; | 64 virtual bool shouldGeneratePixelResults() OVERRIDE; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 void setToolTipText(const blink::WebString&); | 117 void setToolTipText(const blink::WebString&); |
| 121 | 118 |
| 122 bool midiAccessorResult(); | 119 bool midiAccessorResult(); |
| 123 | 120 |
| 124 // A single item in the work queue. | 121 // A single item in the work queue. |
| 125 class WorkItem { | 122 class WorkItem { |
| 126 public: | 123 public: |
| 127 virtual ~WorkItem() {} | 124 virtual ~WorkItem() {} |
| 128 | 125 |
| 129 // Returns true if this started a load. | 126 // Returns true if this started a load. |
| 130 virtual bool Run(::WebTestRunner::WebTestDelegate*, blink::WebView*) = 0; | 127 virtual bool Run(WebTestDelegate*, blink::WebView*) = 0; |
| 131 }; | 128 }; |
| 132 | 129 |
| 133 private: | 130 private: |
| 134 friend class InvokeCallbackTask; | 131 friend class InvokeCallbackTask; |
| 135 friend class TestRunnerBindings; | 132 friend class TestRunnerBindings; |
| 136 friend class WorkQueue; | 133 friend class WorkQueue; |
| 137 | 134 |
| 138 // Helper class for managing events queued by methods like queueLoad or | 135 // Helper class for managing events queued by methods like queueLoad or |
| 139 // queueScript. | 136 // queueScript. |
| 140 class WorkQueue { | 137 class WorkQueue { |
| 141 public: | 138 public: |
| 142 explicit WorkQueue(TestRunner* controller); | 139 explicit WorkQueue(TestRunner* controller); |
| 143 virtual ~WorkQueue(); | 140 virtual ~WorkQueue(); |
| 144 void ProcessWorkSoon(); | 141 void ProcessWorkSoon(); |
| 145 | 142 |
| 146 // Reset the state of the class between tests. | 143 // Reset the state of the class between tests. |
| 147 void Reset(); | 144 void Reset(); |
| 148 | 145 |
| 149 void AddWork(WorkItem*); | 146 void AddWork(WorkItem*); |
| 150 | 147 |
| 151 void set_frozen(bool frozen) { frozen_ = frozen; } | 148 void set_frozen(bool frozen) { frozen_ = frozen; } |
| 152 bool is_empty() { return queue_.empty(); } | 149 bool is_empty() { return queue_.empty(); } |
| 153 ::WebTestRunner::WebTaskList* taskList() { return &task_list_; } | 150 WebTaskList* taskList() { return &task_list_; } |
| 154 | 151 |
| 155 private: | 152 private: |
| 156 void ProcessWork(); | 153 void ProcessWork(); |
| 157 | 154 |
| 158 class WorkQueueTask : public ::WebTestRunner::WebMethodTask<WorkQueue> { | 155 class WorkQueueTask : public WebMethodTask<WorkQueue> { |
| 159 public: | 156 public: |
| 160 WorkQueueTask(WorkQueue* object) : | 157 WorkQueueTask(WorkQueue* object) : WebMethodTask<WorkQueue>(object) {} |
| 161 ::WebTestRunner::WebMethodTask<WorkQueue>(object) { } | |
| 162 | 158 |
| 163 virtual void runIfValid() OVERRIDE; | 159 virtual void runIfValid() OVERRIDE; |
| 164 }; | 160 }; |
| 165 | 161 |
| 166 ::WebTestRunner::WebTaskList task_list_; | 162 WebTaskList task_list_; |
| 167 std::deque<WorkItem*> queue_; | 163 std::deque<WorkItem*> queue_; |
| 168 bool frozen_; | 164 bool frozen_; |
| 169 TestRunner* controller_; | 165 TestRunner* controller_; |
| 170 }; | 166 }; |
| 171 | 167 |
| 172 /////////////////////////////////////////////////////////////////////////// | 168 /////////////////////////////////////////////////////////////////////////// |
| 173 // Methods dealing with the test logic | 169 // Methods dealing with the test logic |
| 174 | 170 |
| 175 // By default, tests end when page load is complete. These methods are used | 171 // By default, tests end when page load is complete. These methods are used |
| 176 // to delay the completion of the test until notifyDone is called. | 172 // to delay the completion of the test until notifyDone is called. |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 bool should_stay_on_page_after_handling_before_unload_; | 667 bool should_stay_on_page_after_handling_before_unload_; |
| 672 | 668 |
| 673 bool should_dump_resource_priorities_; | 669 bool should_dump_resource_priorities_; |
| 674 | 670 |
| 675 std::set<std::string> http_headers_to_clear_; | 671 std::set<std::string> http_headers_to_clear_; |
| 676 | 672 |
| 677 // WAV audio data is stored here. | 673 // WAV audio data is stored here. |
| 678 std::vector<unsigned char> audio_data_; | 674 std::vector<unsigned char> audio_data_; |
| 679 | 675 |
| 680 // Used for test timeouts. | 676 // Used for test timeouts. |
| 681 ::WebTestRunner::WebTaskList task_list_; | 677 WebTaskList task_list_; |
| 682 | 678 |
| 683 ::WebTestRunner::TestInterfaces* test_interfaces_; | 679 TestInterfaces* test_interfaces_; |
| 684 ::WebTestRunner::WebTestDelegate* delegate_; | 680 WebTestDelegate* delegate_; |
| 685 blink::WebView* web_view_; | 681 blink::WebView* web_view_; |
| 686 TestPageOverlay* page_overlay_; | 682 TestPageOverlay* page_overlay_; |
| 687 WebTestProxyBase* proxy_; | 683 WebTestProxyBase* proxy_; |
| 688 | 684 |
| 689 // This is non-0 IFF a load is in progress. | 685 // This is non-0 IFF a load is in progress. |
| 690 blink::WebFrame* top_loading_frame_; | 686 blink::WebFrame* top_loading_frame_; |
| 691 | 687 |
| 692 // WebPermissionClient mock object. | 688 // WebPermissionClient mock object. |
| 693 scoped_ptr<WebPermissions> web_permissions_; | 689 scoped_ptr<WebPermissions> web_permissions_; |
| 694 | 690 |
| 695 scoped_ptr<NotificationPresenter> notification_presenter_; | 691 scoped_ptr<NotificationPresenter> notification_presenter_; |
| 696 | 692 |
| 697 bool pointer_locked_; | 693 bool pointer_locked_; |
| 698 enum { | 694 enum { |
| 699 PointerLockWillSucceed, | 695 PointerLockWillSucceed, |
| 700 PointerLockWillRespondAsync, | 696 PointerLockWillRespondAsync, |
| 701 PointerLockWillFailSync, | 697 PointerLockWillFailSync, |
| 702 } pointer_lock_planned_result_; | 698 } pointer_lock_planned_result_; |
| 703 bool use_mock_theme_; | 699 bool use_mock_theme_; |
| 704 | 700 |
| 705 base::WeakPtrFactory<TestRunner> weak_factory_; | 701 base::WeakPtrFactory<TestRunner> weak_factory_; |
| 706 | 702 |
| 707 DISALLOW_COPY_AND_ASSIGN(TestRunner); | 703 DISALLOW_COPY_AND_ASSIGN(TestRunner); |
| 708 }; | 704 }; |
| 709 | 705 |
| 710 } // namespace content | 706 } // namespace content |
| 711 | 707 |
| 712 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_TEST_RUNNER_H_ | 708 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_TEST_RUNNER_H_ |
| OLD | NEW |