From f55e45a8593acce4a596c39f63ac371d55ff6769 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Mon, 13 Jul 2015 22:18:01 -0700 Subject: [PATCH] Remove //sky/tools/tester This target is unused. TBR=eseidel@google.com Review URL: https://codereview.chromium.org/1235053003 . --- BUILD.gn | 1 - tools/tester/BUILD.gn | 31 ------ tools/tester/test_harness_impl.cc | 36 ------- tools/tester/test_harness_impl.h | 39 ------- tools/tester/test_runner.cc | 77 -------------- tools/tester/test_runner.h | 57 ---------- tools/tester/tester.cc | 171 ------------------------------ 7 files changed, 412 deletions(-) delete mode 100644 tools/tester/BUILD.gn delete mode 100644 tools/tester/test_harness_impl.cc delete mode 100644 tools/tester/test_harness_impl.h delete mode 100644 tools/tester/test_runner.cc delete mode 100644 tools/tester/test_runner.h delete mode 100644 tools/tester/tester.cc diff --git a/BUILD.gn b/BUILD.gn index 868218ad0..056d593d1 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -12,7 +12,6 @@ group("sky") { "//sky/sdk/example", "//sky/tools/imagediff", "//sky/tools/packager($host_toolchain)", - "//sky/tools/tester", "//sky/viewer", ":sky_dev", ] diff --git a/tools/tester/BUILD.gn b/tools/tester/BUILD.gn deleted file mode 100644 index 2db5dbe47..000000000 --- a/tools/tester/BUILD.gn +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright 2014 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import("//mojo/public/mojo_application.gni") - -mojo_native_application("tester") { - output_name = "sky_tester" - - sources = [ - "test_harness_impl.cc", - "test_harness_impl.h", - "test_runner.cc", - "test_runner.h", - "tester.cc", - ] - - deps = [ - "//base", - "//mojo/application", - "//mojo/converters/geometry", - "//mojo/converters/input_events", - "//mojo/public/cpp/bindings", - "//mojo/public/cpp/system", - "//mojo/public/cpp/utility", - "//mojo/services/input_events/public/interfaces", - "//mojo/services/view_manager/public/cpp", - "//services/window_manager:lib", - "//sky/services/testing:interfaces", - ] -} diff --git a/tools/tester/test_harness_impl.cc b/tools/tester/test_harness_impl.cc deleted file mode 100644 index 1ece58c17..000000000 --- a/tools/tester/test_harness_impl.cc +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "sky/tools/tester/test_harness_impl.h" - -#include "sky/tools/tester/test_runner.h" - -namespace sky { -namespace tester { - -TestHarnessImpl::TestHarnessImpl(TestRunner* test_runner, - mojo::InterfaceRequest request) - : binding_(this, request.Pass()), test_runner_(test_runner->GetWeakPtr()) { - // FIXME: This is technically when the V8 context gets created and - // not when the test is started. An error before we instantiated - // the V8 context would show up before the #BEGIN line for this test. - test_runner->OnTestStart(); -} - -TestHarnessImpl::~TestHarnessImpl() { -} - -void TestHarnessImpl::OnTestComplete(const mojo::String& test_result, - const mojo::Array pixels) { - if (test_runner_) - test_runner_->OnTestComplete(test_result, pixels); -} - -void TestHarnessImpl::DispatchInputEvent(mojo::EventPtr event) { - if (test_runner_) - test_runner_->client()->DispatchInputEvent(event.Pass()); -} - -} // namespace tester -} // namespace sky diff --git a/tools/tester/test_harness_impl.h b/tools/tester/test_harness_impl.h deleted file mode 100644 index 18f86966e..000000000 --- a/tools/tester/test_harness_impl.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef SKY_TOOLS_TESTER_TEST_HARNESS_IMPL_H_ -#define SKY_TOOLS_TESTER_TEST_HARNESS_IMPL_H_ - -#include "base/memory/weak_ptr.h" -#include "mojo/public/cpp/application/interface_factory_impl.h" -#include "mojo/public/cpp/bindings/strong_binding.h" -#include "mojo/public/cpp/system/core.h" -#include "sky/services/testing/test_harness.mojom.h" - -namespace sky { -namespace tester { -class TestRunner; - -class TestHarnessImpl : public TestHarness { - public: - TestHarnessImpl(TestRunner* runner, - mojo::InterfaceRequest request); - ~TestHarnessImpl() override; - - private: - // TestHarness implementation. - void OnTestComplete(const mojo::String& test_result, - const mojo::Array pixels) override; - void DispatchInputEvent(mojo::EventPtr event) override; - - mojo::StrongBinding binding_; - base::WeakPtr test_runner_; - - MOJO_DISALLOW_COPY_AND_ASSIGN(TestHarnessImpl); -}; - -} // namespace tester -} // namespace sky - -#endif // SKY_TOOLS_TESTER_TEST_HARNESS_IMPL_H_ diff --git a/tools/tester/test_runner.cc b/tools/tester/test_runner.cc deleted file mode 100644 index 5982382a5..000000000 --- a/tools/tester/test_runner.cc +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "sky/tools/tester/test_runner.h" - -#include -#include "base/bind.h" -#include "mojo/public/cpp/application/connect.h" -#include "mojo/services/view_manager/public/cpp/view.h" - -namespace sky { -namespace tester { - -TestRunnerClient::~TestRunnerClient() { -} - -TestRunner::TestRunner(TestRunnerClient* client, - mojo::View* container, - const std::string& url, - bool enable_pixel_dumping) - : client_(client), - enable_pixel_dumping_(enable_pixel_dumping), - weak_ptr_factory_(this) { - CHECK(client); - - mojo::ServiceProviderPtr test_harness_provider; - test_harness_provider_impl_.AddService(this); - test_harness_provider_impl_.Bind(GetProxy(&test_harness_provider)); - - container->Embed(url, nullptr, test_harness_provider.Pass()); -} - -TestRunner::~TestRunner() { -} - -base::WeakPtr TestRunner::GetWeakPtr() { - return weak_ptr_factory_.GetWeakPtr(); -} - -void TestRunner::OnTestStart() { - std::cout << "#BEGIN\n"; - std::cout.flush(); -} - -void TestRunner::OnTestComplete(const std::string& test_result, - const mojo::Array& pixels) { - std::cout << "Content-Type: text/plain\n"; - std::cout << test_result << "\n"; - std::cout << "#EOF\n"; - - // TODO(ojan): Don't generate the pixels if enable_pixel_dumping_ is false. - if (enable_pixel_dumping_) { - // TODO(ojan): Add real hashes here once we want to do pixel tests. - std::cout << "\nActualHash: FAKEHASHSTUB\n"; - std::cout << "Content-Type: image/png\n"; - std::cout << "Content-Length: " << pixels.size() << "\n"; - CHECK(pixels.size()) << "Could not dump pixels. Did you call notifyTestComplete before the first paint?"; - std::cout.write( - reinterpret_cast(&pixels[0]), pixels.size()); - } - - std::cout << "#EOF\n"; - std::cout.flush(); - std::cerr << "#EOF\n"; - std::cerr.flush(); - - client_->OnTestComplete(); -} - -void TestRunner::Create(mojo::ApplicationConnection* app, - mojo::InterfaceRequest request) { - new TestHarnessImpl(this, request.Pass()); -} - -} // namespace tester -} // namespace sky diff --git a/tools/tester/test_runner.h b/tools/tester/test_runner.h deleted file mode 100644 index 88102407a..000000000 --- a/tools/tester/test_runner.h +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef SKY_TOOLS_TESTER_TEST_RUNNER_H_ -#define SKY_TOOLS_TESTER_TEST_RUNNER_H_ - -#include "base/memory/weak_ptr.h" -#include "mojo/public/cpp/application/service_provider_impl.h" -#include "sky/tools/tester/test_harness_impl.h" - -namespace mojo{ -class View; -} - -namespace sky { -namespace tester { - -class TestRunnerClient { - public: - virtual void OnTestComplete() = 0; - virtual void DispatchInputEvent(mojo::EventPtr event) = 0; - - protected: - virtual ~TestRunnerClient(); -}; - -class TestRunner : public mojo::InterfaceFactory { - public: - TestRunner(TestRunnerClient* client, mojo::View* container, - const std::string& url, bool enable_pixel_dumping); - ~TestRunner() override; - - TestRunnerClient* client() const { return client_; } - - base::WeakPtr GetWeakPtr(); - void OnTestStart(); - void OnTestComplete(const std::string& test_result, - const mojo::Array& pixels); - - private: - // mojo::InterfaceFactory implementation: - void Create(mojo::ApplicationConnection* app, - mojo::InterfaceRequest request) override; - - mojo::ServiceProviderImpl test_harness_provider_impl_; - TestRunnerClient* client_; - bool enable_pixel_dumping_; - base::WeakPtrFactory weak_ptr_factory_; - - MOJO_DISALLOW_COPY_AND_ASSIGN(TestRunner); -}; - -} // namespace tester -} // namespace sky - -#endif // SKY_TOOLS_TESTER_TEST_RUNNER_H_ diff --git a/tools/tester/tester.cc b/tools/tester/tester.cc deleted file mode 100644 index ae2de39ee..000000000 --- a/tools/tester/tester.cc +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include -#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" -#include "mojo/public/cpp/application/application_impl.h" -#include "mojo/public/cpp/application/connect.h" -#include "mojo/public/cpp/application/service_provider_impl.h" -#include "mojo/services/input_events/public/interfaces/input_events.mojom.h" -#include "mojo/services/view_manager/public/cpp/view_manager.h" -#include "mojo/services/view_manager/public/cpp/view_manager_delegate.h" -#include "mojo/services/view_manager/public/cpp/view_observer.h" -#include "services/window_manager/window_manager_app.h" -#include "services/window_manager/window_manager_delegate.h" -#include "sky/tools/tester/test_runner.h" - -namespace sky { -namespace tester { -namespace { - -struct UrlData { - std::string url; - std::string expected_pixel_hash; - bool enable_pixel_dumping = false; -}; - -void WaitForURL(UrlData& data) { - // A test name is formated like file:///path/to/test'--pixel-test'pixelhash - std::cin >> data.url; - - std::string pixel_switch; - std::string::size_type separator_position = data.url.find('\''); - if (separator_position != std::string::npos) { - pixel_switch = data.url.substr(separator_position + 1); - data.url.erase(separator_position); - } - - std::string pixel_hash; - separator_position = pixel_switch.find('\''); - if (separator_position != std::string::npos) { - pixel_hash = pixel_switch.substr(separator_position + 1); - pixel_switch.erase(separator_position); - } - - data.enable_pixel_dumping = pixel_switch == "--pixel-test"; - data.expected_pixel_hash = pixel_hash; -} - -} // namespace - -class SkyTester : public mojo::ApplicationDelegate, - public mojo::ViewManagerDelegate, - public window_manager::WindowManagerDelegate, - public mojo::ViewObserver, - public TestRunnerClient { - public: - SkyTester() - : window_manager_app_(new window_manager::WindowManagerApp(this, this)), - root_(NULL), - content_(NULL), - weak_ptr_factory_(this) {} - ~SkyTester() override {} - - private: - // Overridden from mojo::ApplicationDelegate: - void Initialize(mojo::ApplicationImpl* impl) override { - window_manager_app_->Initialize(impl); - - if (impl->args().size() >= 2) - url_from_args_ = impl->args()[1]; - } - bool ConfigureIncomingConnection( - mojo::ApplicationConnection* connection) override { - window_manager_app_->ConfigureIncomingConnection(connection); - if (test_runner_) - connection->AddService(test_runner_.get()); - return true; - } - - // Overridden from mojo::ViewManagerDelegate: - void OnEmbed(mojo::View* root, - mojo::InterfaceRequest services, - mojo::ServiceProviderPtr exposed_services) override { - root_ = root; - root_->AddObserver(this); - - content_ = root->view_manager()->CreateView(); - content_->SetBounds(root_->bounds()); - root_->AddChild(content_); - content_->SetVisible(true); - - std::cout << "#READY\n"; - std::cout.flush(); - ScheduleRun(); - } - - // Overridden from window_manager::WindowManagerDelegate: - void Embed(const mojo::String& url, - mojo::InterfaceRequest services, - mojo::ServiceProviderPtr exposed_services) override {} - - void OnViewManagerDisconnected(mojo::ViewManager* view_manager) override { - root_ = NULL; - } - - void OnViewDestroyed(mojo::View* view) override { - view->RemoveObserver(this); - } - - void OnViewBoundsChanged(mojo::View* view, - const mojo::Rect& old_bounds, - const mojo::Rect& new_bounds) override { - 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_); - - UrlData data; - if (url_from_args_.length()) { - data.url = url_from_args_; - } else { - WaitForURL(data); - } - - test_runner_.reset(new TestRunner(this, content_, data.url, - data.enable_pixel_dumping)); - } - - void OnTestComplete() override { - test_runner_.reset(); - if (url_from_args_.length()) - exit(0); - ScheduleRun(); - } - - void DispatchInputEvent(mojo::EventPtr event) override { - window_manager_app_->DispatchInputEventToView(content_, event.Pass()); - } - - scoped_ptr window_manager_app_; - - std::string url_from_args_; - - mojo::View* root_; - mojo::View* content_; - - scoped_ptr test_runner_; - - base::WeakPtrFactory weak_ptr_factory_; - - DISALLOW_COPY_AND_ASSIGN(SkyTester); -}; - -} // namespace tester -} // namespace examples - -MojoResult MojoMain(MojoHandle application_request) { - mojo::ApplicationRunnerChromium runner(new sky::tester::SkyTester); - return runner.Run(application_request); -} -- GitLab