mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
This removes the symmetrical nature of ServiceProvider and consistently passes and uses a ServiceProvider + ServiceProvider& pair in places that wish to bidirectionally expose services, such as the view manager. The view manager library now deals with InterfaceRequest<ServiceProvider> and ServiceProviderPtr objects (i.e. c++ wrappers for handles) instead of a concrete implementation of ServiceProvider to make it easier for callers. A number of places that were assuming a particular ServiceProvider would always exist are updated to reflect the nullability of the parameters in mojom and places that do not wish to ever look up or provide services now pass nullptr instead of doomed pipe handles. The JS application startup classes are reworked a bit to accomodate exposing services on the third ConnectToApplication/AcceptConnection parameter. BUG=449432 R=abarth@chromium.org, sky@chromium.org Review URL: https://codereview.chromium.org/858103002
72 lines
2.1 KiB
C++
72 lines
2.1 KiB
C++
// 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)
|
|
: test_harness_factory_(this),
|
|
client_(client),
|
|
weak_ptr_factory_(this),
|
|
enable_pixel_dumping_(enable_pixel_dumping) {
|
|
CHECK(client);
|
|
|
|
mojo::ServiceProviderPtr test_harness_provider;
|
|
test_harness_provider_impl_.AddService(&test_harness_factory_);
|
|
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();
|
|
}
|
|
|
|
} // namespace tester
|
|
} // namespace sky
|