mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Remove //sky/tools/tester
This target is unused. TBR=eseidel@google.com Review URL: https://codereview.chromium.org/1235053003 .
This commit is contained in:
parent
7ce0501a7e
commit
f55e45a859
1
BUILD.gn
1
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",
|
||||
]
|
||||
|
||||
@ -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",
|
||||
]
|
||||
}
|
||||
@ -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<TestHarness> 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<uint8_t> 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
|
||||
@ -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<TestHarness> request);
|
||||
~TestHarnessImpl() override;
|
||||
|
||||
private:
|
||||
// TestHarness implementation.
|
||||
void OnTestComplete(const mojo::String& test_result,
|
||||
const mojo::Array<uint8_t> pixels) override;
|
||||
void DispatchInputEvent(mojo::EventPtr event) override;
|
||||
|
||||
mojo::StrongBinding<TestHarness> binding_;
|
||||
base::WeakPtr<TestRunner> test_runner_;
|
||||
|
||||
MOJO_DISALLOW_COPY_AND_ASSIGN(TestHarnessImpl);
|
||||
};
|
||||
|
||||
} // namespace tester
|
||||
} // namespace sky
|
||||
|
||||
#endif // SKY_TOOLS_TESTER_TEST_HARNESS_IMPL_H_
|
||||
@ -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 <iostream>
|
||||
#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> 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<uint8_t>& 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<const char*>(&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<TestHarness> request) {
|
||||
new TestHarnessImpl(this, request.Pass());
|
||||
}
|
||||
|
||||
} // namespace tester
|
||||
} // namespace sky
|
||||
@ -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<TestHarness> {
|
||||
public:
|
||||
TestRunner(TestRunnerClient* client, mojo::View* container,
|
||||
const std::string& url, bool enable_pixel_dumping);
|
||||
~TestRunner() override;
|
||||
|
||||
TestRunnerClient* client() const { return client_; }
|
||||
|
||||
base::WeakPtr<TestRunner> GetWeakPtr();
|
||||
void OnTestStart();
|
||||
void OnTestComplete(const std::string& test_result,
|
||||
const mojo::Array<uint8_t>& pixels);
|
||||
|
||||
private:
|
||||
// mojo::InterfaceFactory<TestHarness> implementation:
|
||||
void Create(mojo::ApplicationConnection* app,
|
||||
mojo::InterfaceRequest<TestHarness> request) override;
|
||||
|
||||
mojo::ServiceProviderImpl test_harness_provider_impl_;
|
||||
TestRunnerClient* client_;
|
||||
bool enable_pixel_dumping_;
|
||||
base::WeakPtrFactory<TestRunner> weak_ptr_factory_;
|
||||
|
||||
MOJO_DISALLOW_COPY_AND_ASSIGN(TestRunner);
|
||||
};
|
||||
|
||||
} // namespace tester
|
||||
} // namespace sky
|
||||
|
||||
#endif // SKY_TOOLS_TESTER_TEST_RUNNER_H_
|
||||
@ -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 <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"
|
||||
#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<mojo::ServiceProvider> 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<mojo::ServiceProvider> 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::WindowManagerApp> window_manager_app_;
|
||||
|
||||
std::string url_from_args_;
|
||||
|
||||
mojo::View* root_;
|
||||
mojo::View* content_;
|
||||
|
||||
scoped_ptr<TestRunner> test_runner_;
|
||||
|
||||
base::WeakPtrFactory<SkyTester> 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);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user