| Index: sky/tools/tester/tester.cc
|
| diff --git a/sky/tools/tester/tester.cc b/sky/tools/tester/tester.cc
|
| index fd1f4ff45c2dfeb6ee3345ab1c59d23e6437b03e..57815c6fb4ff234a92e4ada01c60b163b65f4cad 100644
|
| --- a/sky/tools/tester/tester.cc
|
| +++ b/sky/tools/tester/tester.cc
|
| @@ -2,6 +2,9 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#include <iostream>
|
| +#include "base/bind.h"
|
| +#include "base/memory/weak_ptr.h"
|
| #include "mojo/application/application_runner_chromium.h"
|
| #include "mojo/public/c/system/main.h"
|
| #include "mojo/public/cpp/application/application_delegate.h"
|
| @@ -14,27 +17,41 @@
|
| #include "mojo/services/public/interfaces/input_events/input_events.mojom.h"
|
| #include "mojo/services/window_manager/window_manager_app.h"
|
| #include "mojo/services/window_manager/window_manager_delegate.h"
|
| -#include "sky/tools/tester/test_harness.h"
|
| +#include "sky/tools/tester/test_runner.h"
|
|
|
| namespace sky {
|
| namespace tester {
|
| +namespace {
|
| +
|
| +std::string WaitForURL() {
|
| + std::string url;
|
| + std::cin >> url;
|
| + return url;
|
| +}
|
| +
|
| +} // namespace
|
|
|
| class SkyTester : public mojo::ApplicationDelegate,
|
| public mojo::ViewManagerDelegate,
|
| public mojo::WindowManagerDelegate,
|
| - public mojo::ViewObserver {
|
| + public mojo::ViewObserver,
|
| + public TestRunnerClient {
|
| public:
|
| SkyTester()
|
| : window_manager_app_(new mojo::WindowManagerApp(this, this)),
|
| view_manager_(NULL),
|
| root_(NULL),
|
| - content_(NULL) {}
|
| + content_(NULL),
|
| + weak_ptr_factory_(this) {}
|
| virtual ~SkyTester() {}
|
|
|
| private:
|
| // Overridden from mojo::ApplicationDelegate:
|
| virtual void Initialize(mojo::ApplicationImpl* impl) override {
|
| window_manager_app_->Initialize(impl);
|
| +
|
| + if (impl->args().size() >= 2)
|
| + url_from_args_ = impl->args()[1];
|
| }
|
| virtual bool ConfigureIncomingConnection(
|
| mojo::ApplicationConnection* connection) override {
|
| @@ -56,8 +73,9 @@ class SkyTester : public mojo::ApplicationDelegate,
|
| content_->SetBounds(root_->bounds());
|
| root_->AddChild(content_);
|
|
|
| - test_harness_.reset(new TestHarness(content_));
|
| - test_harness_->ScheduleRun();
|
| + std::cout << "#READY\n";
|
| + std::cout.flush();
|
| + ScheduleRun();
|
| }
|
|
|
| // Overridden from WindowManagerDelegate:
|
| @@ -82,12 +100,35 @@ class SkyTester : public mojo::ApplicationDelegate,
|
| content_->SetBounds(new_bounds);
|
| }
|
|
|
| + void ScheduleRun() {
|
| + base::MessageLoop::current()->PostTask(FROM_HERE,
|
| + base::Bind(&SkyTester::Run, weak_ptr_factory_.GetWeakPtr()));
|
| + }
|
| +
|
| + void Run() {
|
| + DCHECK(!test_runner_);
|
| + std::string url = url_from_args_.length() ? url_from_args_ : WaitForURL();
|
| + test_runner_.reset(new TestRunner(this, content_, url));
|
| + }
|
| +
|
| + void OnTestComplete() override {
|
| + test_runner_.reset();
|
| + if (url_from_args_.length())
|
| + exit(0);
|
| + ScheduleRun();
|
| + }
|
| +
|
| scoped_ptr<mojo::WindowManagerApp> window_manager_app_;
|
|
|
| + std::string url_from_args_;
|
| +
|
| mojo::ViewManager* view_manager_;
|
| mojo::View* root_;
|
| mojo::View* content_;
|
| - scoped_ptr<TestHarness> test_harness_;
|
| +
|
| + scoped_ptr<TestRunner> test_runner_;
|
| +
|
| + base::WeakPtrFactory<SkyTester> weak_ptr_factory_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(SkyTester);
|
| };
|
|
|