blob: 57bfab2cac22c0ab19da35ea4e03ae81609b0ae1 [file] [log] [blame]
Adam Barth06caa3d2014-10-23 11:15:41 -07001// 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 Robinson3b679672015-01-21 18:36:01 -08009#include "mojo/public/cpp/application/service_provider_impl.h"
Adam Barth129a5252014-11-11 16:43:21 -080010#include "sky/tools/tester/test_harness_impl.h"
Adam Barth06caa3d2014-10-23 11:15:41 -070011
12namespace mojo{
13class View;
14}
15
16namespace sky {
17namespace tester {
18
19class TestRunnerClient {
20 public:
21 virtual void OnTestComplete() = 0;
Adam Barth3d683fc2014-11-12 10:46:35 -080022 virtual void DispatchInputEvent(mojo::EventPtr event) = 0;
23
24 protected:
25 virtual ~TestRunnerClient();
Adam Barth06caa3d2014-10-23 11:15:41 -070026};
27
James Robinsond3495a12015-02-18 18:17:50 -080028class TestRunner : public mojo::InterfaceFactory<TestHarness> {
Adam Barth06caa3d2014-10-23 11:15:41 -070029 public:
30 TestRunner(TestRunnerClient* client, mojo::View* container,
Ojan Vafai9e174d22014-12-12 16:45:49 -080031 const std::string& url, bool enable_pixel_dumping);
James Robinsond3495a12015-02-18 18:17:50 -080032 ~TestRunner() override;
Adam Barth06caa3d2014-10-23 11:15:41 -070033
Adam Barth3d683fc2014-11-12 10:46:35 -080034 TestRunnerClient* client() const { return client_; }
Adam Barth3d683fc2014-11-12 10:46:35 -080035
Adam Barth06caa3d2014-10-23 11:15:41 -070036 base::WeakPtr<TestRunner> GetWeakPtr();
37 void OnTestStart();
Ojan Vafai9e174d22014-12-12 16:45:49 -080038 void OnTestComplete(const std::string& test_result,
39 const mojo::Array<uint8_t>& pixels);
Adam Barth06caa3d2014-10-23 11:15:41 -070040
41 private:
James Robinsond3495a12015-02-18 18:17:50 -080042 // mojo::InterfaceFactory<TestHarness> implementation:
43 void Create(mojo::ApplicationConnection* app,
44 mojo::InterfaceRequest<TestHarness> request) override;
45
James Robinson3b679672015-01-21 18:36:01 -080046 mojo::ServiceProviderImpl test_harness_provider_impl_;
Adam Barth06caa3d2014-10-23 11:15:41 -070047 TestRunnerClient* client_;
48 base::WeakPtrFactory<TestRunner> weak_ptr_factory_;
Ojan Vafai9e174d22014-12-12 16:45:49 -080049 bool enable_pixel_dumping_;
Adam Barth06caa3d2014-10-23 11:15:41 -070050
51 MOJO_DISALLOW_COPY_AND_ASSIGN(TestRunner);
52};
53
54} // namespace tester
55} // namespace sky
56
57#endif // SKY_TOOLS_TESTER_TEST_RUNNER_H_