Use sky_shell instead of mojo_shell for testing.
This does way more than a single CL should do, sorry. - Fixed a bunch of logging/error reporting during loads. - Made it possible for --package-root to be absolute. - Fixed (hypothetically) parts of iOS build to be clang-plugin-compliant. - Made all tests pass in sky_shell - Removed a bunch of layout_tests including windows support. I'll remove all the mojo test harness stuff in a follow-up patch. R=abarth@chromium.org, abarth@google.com Review URL: https://codereview.chromium.org/1215953006.
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "sky/shell/dart/dart_library_provider_files.h"
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/threading/worker_pool.h"
|
||||
#include "mojo/common/data_pipe_utils.h"
|
||||
@@ -14,14 +15,18 @@ namespace sky {
|
||||
namespace shell {
|
||||
namespace {
|
||||
|
||||
void Ignored(bool) {
|
||||
void CopyComplete(base::FilePath file, bool success) {
|
||||
if (!success)
|
||||
LOG(ERROR) << "Failed to load " << file.AsUTF8Unsafe();
|
||||
}
|
||||
|
||||
base::FilePath SimplifyPath(const base::FilePath& path) {
|
||||
std::vector<base::FilePath::StringType> components;
|
||||
path.GetComponents(&components);
|
||||
base::FilePath result;
|
||||
for (const auto& component : components) {
|
||||
auto it = components.begin();
|
||||
base::FilePath result(*it++);
|
||||
for (; it != components.end(); it++) {
|
||||
auto& component = *it;
|
||||
if (component == base::FilePath::kCurrentDirectory)
|
||||
continue;
|
||||
if (component == base::FilePath::kParentDirectory)
|
||||
@@ -37,6 +42,8 @@ base::FilePath SimplifyPath(const base::FilePath& path) {
|
||||
DartLibraryProviderFiles::DartLibraryProviderFiles(
|
||||
const base::FilePath& package_root)
|
||||
: package_root_(package_root) {
|
||||
CHECK(base::DirectoryExists(package_root_)) << "Invalid --package-root "
|
||||
<< "\"" << package_root_.LossyDisplayName() << "\"";
|
||||
}
|
||||
|
||||
DartLibraryProviderFiles::~DartLibraryProviderFiles() {
|
||||
@@ -52,7 +59,7 @@ void DartLibraryProviderFiles::GetLibraryAsStream(
|
||||
scoped_refptr<base::TaskRunner> runner =
|
||||
base::WorkerPool::GetTaskRunner(true);
|
||||
mojo::common::CopyFromFile(source, pipe.producer_handle.Pass(), 0,
|
||||
runner.get(), base::Bind(&Ignored));
|
||||
runner.get(), base::Bind(&CopyComplete, source));
|
||||
}
|
||||
|
||||
std::string DartLibraryProviderFiles::CanonicalizePackageURL(std::string url) {
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "base/i18n/icu_util.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "sky/engine/public/web/WebRuntimeFeatures.h"
|
||||
#include "sky/shell/platform_view.h"
|
||||
#include "sky/shell/service_provider.h"
|
||||
#include "sky/shell/shell.h"
|
||||
@@ -24,15 +25,20 @@ namespace {
|
||||
|
||||
void Usage() {
|
||||
std::cerr << "Usage: sky_shell"
|
||||
<< " --" << switches::kNonInteractive
|
||||
<< " --" << switches::kPackageRoot << "=PACKAGE_ROOT"
|
||||
<< " [ MAIN_DART ]" << std::endl;
|
||||
}
|
||||
|
||||
void Init() {
|
||||
base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess();
|
||||
blink::WebRuntimeFeatures::enableObservatory(
|
||||
!command_line.HasSwitch(switches::kNonInteractive));
|
||||
|
||||
Shell::Init(make_scoped_ptr(new ServiceProviderContext(
|
||||
base::MessageLoop::current()->task_runner())));
|
||||
|
||||
base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess();
|
||||
// Explicitly boot the shared test runner.
|
||||
TestRunner& runner = TestRunner::Shared();
|
||||
|
||||
std::string package_root =
|
||||
command_line.GetSwitchValueASCII(switches::kPackageRoot);
|
||||
@@ -42,8 +48,8 @@ void Init() {
|
||||
if (!args.empty())
|
||||
main = args[0];
|
||||
|
||||
TestRunner::Shared().set_package_root(package_root);
|
||||
TestRunner::Shared().Start(main);
|
||||
runner.set_package_root(package_root);
|
||||
runner.Start(main);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace shell {
|
||||
namespace switches {
|
||||
|
||||
const char kHelp[] = "help";
|
||||
const char kNonInteractive[] = "non-interactive";
|
||||
const char kPackageRoot[] = "package-root";
|
||||
const char kSnapshot[] = "snapshot";
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace switches {
|
||||
|
||||
extern const char kHelp[];
|
||||
extern const char kPackageRoot[];
|
||||
extern const char kNonInteractive[];
|
||||
extern const char kSnapshot[];
|
||||
|
||||
} // namespace switches
|
||||
|
||||
@@ -62,8 +62,8 @@ TestRunner::TestRunner()
|
||||
|
||||
shell_view_->view()->ConnectToEngine(GetProxy(&sky_engine_));
|
||||
ViewportMetricsPtr metrics = ViewportMetrics::New();
|
||||
metrics->physical_width = 320;
|
||||
metrics->physical_height = 640;
|
||||
metrics->physical_width = 800;
|
||||
metrics->physical_height = 600;
|
||||
sky_engine_->OnViewportMetricsChanged(metrics.Pass());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import "dart:sky.internals" as internals;
|
||||
import "../resources/harness.dart";
|
||||
|
||||
void main() {
|
||||
internals.notifyTestComplete("PASS");
|
||||
notifyTestComplete("PASS");
|
||||
}
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
CONSOLE: url => http://127.0.0.1:8000/sky/tests/services/resources/pass.txt
|
||||
CONSOLE: status_line => HTTP/1.1 200 OK
|
||||
CONSOLE: mime_type => text/plain
|
||||
CONSOLE: read 31 bytes
|
||||
This is data from the network.
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
import 'dart:async';
|
||||
import 'dart:typed_data';
|
||||
import "dart:sky.internals" as internals;
|
||||
|
||||
import 'package:mojo/bindings.dart';
|
||||
import 'package:mojo/core.dart';
|
||||
import 'package:mojom/mojo/network_service.mojom.dart';
|
||||
import 'package:mojom/mojo/url_request.mojom.dart';
|
||||
import 'package:mojom/mojo/url_loader.mojom.dart';
|
||||
|
||||
import 'package:sky/mojo/embedder.dart';
|
||||
|
||||
Future<String> run(url) async {
|
||||
var networkService= new NetworkServiceProxy.unbound();
|
||||
embedder.connectToService("mojo:authenticated_network_service",
|
||||
networkService);
|
||||
|
||||
var urlLoader = new UrlLoaderProxy.unbound();
|
||||
networkService.ptr.createUrlLoader(urlLoader);
|
||||
|
||||
var urlRequest = new UrlRequest()
|
||||
..url = url
|
||||
..autoFollowRedirects = true;
|
||||
var urlResponse = await urlLoader.ptr.start(urlRequest);
|
||||
|
||||
urlLoader.close();
|
||||
networkService.close();
|
||||
|
||||
print("url => ${urlResponse.response.url}");
|
||||
print("status_line => ${urlResponse.response.statusLine}");
|
||||
print("mime_type => ${urlResponse.response.mimeType}");
|
||||
|
||||
ByteData bodyData =
|
||||
await DataPipeDrainer.drainHandle(urlResponse.response.body);
|
||||
print("read ${bodyData.lengthInBytes} bytes");
|
||||
|
||||
return new String.fromCharCodes(new Uint8List.view(bodyData.buffer));
|
||||
}
|
||||
|
||||
main() async {
|
||||
var url = "http://127.0.0.1:8000/sky/tests/services/resources/pass.txt";
|
||||
var result = await run(url);
|
||||
internals.notifyTestComplete(result);
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
#!mojo mojo:js_content_handler
|
||||
|
||||
define("main", [
|
||||
"console",
|
||||
"mojo/public/js/bindings",
|
||||
"mojo/services/public/js/application",
|
||||
"mojo/services/view_manager/public/interfaces/view_manager.mojom",
|
||||
"services/js/test/echo_service.mojom",
|
||||
], function(console, bindings, application, viewManagerMojom, echoServiceMojom) {
|
||||
|
||||
const Application = application.Application;
|
||||
const ViewManagerClient = viewManagerMojom.ViewManagerClient;
|
||||
const EchoService = echoServiceMojom.EchoService;
|
||||
|
||||
var serviceImpl;
|
||||
var success = new Promise(function(resolve) {
|
||||
serviceImpl = {
|
||||
onEmbed: function() {
|
||||
resolve({value: "success"});
|
||||
},
|
||||
echoString: function(s) {
|
||||
return success;
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
class IFrameVMCApp extends Application {
|
||||
acceptConnection(initiatorURL, initiatorServiceExchange) {
|
||||
var factory = function() { return serviceImpl; }
|
||||
initiatorServiceExchange.provideService(ViewManagerClient, factory);
|
||||
initiatorServiceExchange.provideService(EchoService, factory);
|
||||
}
|
||||
}
|
||||
|
||||
return IFrameVMCApp;
|
||||
});
|
||||
@@ -1 +0,0 @@
|
||||
This is data from the network.
|
||||
Reference in New Issue
Block a user