Adam Barth | 06caa3d | 2014-10-23 11:15:41 -0700 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef SKY_TOOLS_TESTER_TEST_RUNNER_H_ |
| 6 | #define SKY_TOOLS_TESTER_TEST_RUNNER_H_ |
| 7 | |
| 8 | #include "base/memory/weak_ptr.h" |
James Robinson | 3b67967 | 2015-01-21 18:36:01 -0800 | [diff] [blame] | 9 | #include "mojo/public/cpp/application/service_provider_impl.h" |
Adam Barth | 129a525 | 2014-11-11 16:43:21 -0800 | [diff] [blame] | 10 | #include "sky/tools/tester/test_harness_impl.h" |
Adam Barth | 06caa3d | 2014-10-23 11:15:41 -0700 | [diff] [blame] | 11 | |
| 12 | namespace mojo{ |
| 13 | class View; |
| 14 | } |
| 15 | |
| 16 | namespace sky { |
| 17 | namespace tester { |
| 18 | |
| 19 | class TestRunnerClient { |
| 20 | public: |
| 21 | virtual void OnTestComplete() = 0; |
Adam Barth | 3d683fc | 2014-11-12 10:46:35 -0800 | [diff] [blame] | 22 | virtual void DispatchInputEvent(mojo::EventPtr event) = 0; |
| 23 | |
| 24 | protected: |
| 25 | virtual ~TestRunnerClient(); |
Adam Barth | 06caa3d | 2014-10-23 11:15:41 -0700 | [diff] [blame] | 26 | }; |
| 27 | |
James Robinson | d3495a1 | 2015-02-18 18:17:50 -0800 | [diff] [blame] | 28 | class TestRunner : public mojo::InterfaceFactory<TestHarness> { |
Adam Barth | 06caa3d | 2014-10-23 11:15:41 -0700 | [diff] [blame] | 29 | public: |
| 30 | TestRunner(TestRunnerClient* client, mojo::View* container, |
Ojan Vafai | 9e174d2 | 2014-12-12 16:45:49 -0800 | [diff] [blame] | 31 | const std::string& url, bool enable_pixel_dumping); |
James Robinson | d3495a1 | 2015-02-18 18:17:50 -0800 | [diff] [blame] | 32 | ~TestRunner() override; |
Adam Barth | 06caa3d | 2014-10-23 11:15:41 -0700 | [diff] [blame] | 33 | |
Adam Barth | 3d683fc | 2014-11-12 10:46:35 -0800 | [diff] [blame] | 34 | TestRunnerClient* client() const { return client_; } |
Adam Barth | 3d683fc | 2014-11-12 10:46:35 -0800 | [diff] [blame] | 35 | |
Adam Barth | 06caa3d | 2014-10-23 11:15:41 -0700 | [diff] [blame] | 36 | base::WeakPtr<TestRunner> GetWeakPtr(); |
| 37 | void OnTestStart(); |
Ojan Vafai | 9e174d2 | 2014-12-12 16:45:49 -0800 | [diff] [blame] | 38 | void OnTestComplete(const std::string& test_result, |
| 39 | const mojo::Array<uint8_t>& pixels); |
Adam Barth | 06caa3d | 2014-10-23 11:15:41 -0700 | [diff] [blame] | 40 | |
| 41 | private: |
James Robinson | d3495a1 | 2015-02-18 18:17:50 -0800 | [diff] [blame] | 42 | // mojo::InterfaceFactory<TestHarness> implementation: |
| 43 | void Create(mojo::ApplicationConnection* app, |
| 44 | mojo::InterfaceRequest<TestHarness> request) override; |
| 45 | |
James Robinson | 3b67967 | 2015-01-21 18:36:01 -0800 | [diff] [blame] | 46 | mojo::ServiceProviderImpl test_harness_provider_impl_; |
Adam Barth | 06caa3d | 2014-10-23 11:15:41 -0700 | [diff] [blame] | 47 | TestRunnerClient* client_; |
| 48 | base::WeakPtrFactory<TestRunner> weak_ptr_factory_; |
Ojan Vafai | 9e174d2 | 2014-12-12 16:45:49 -0800 | [diff] [blame] | 49 | bool enable_pixel_dumping_; |
Adam Barth | 06caa3d | 2014-10-23 11:15:41 -0700 | [diff] [blame] | 50 | |
| 51 | MOJO_DISALLOW_COPY_AND_ASSIGN(TestRunner); |
| 52 | }; |
| 53 | |
| 54 | } // namespace tester |
| 55 | } // namespace sky |
| 56 | |
| 57 | #endif // SKY_TOOLS_TESTER_TEST_RUNNER_H_ |