Files
engine/shell/testing/test_runner.cc
T
Ian Hickson 87398c9c77 Move the test runner to a higher DPI screen. (#3688)
Having the device pixel ratio of the test shell be 1.0x makes it
unlikely that we will catch errors relating to mishandling of the
device pixel ratio in the test shell.

This patch arbitrarily increases the device pixel resolution while
keeping the logical resolution the same.
2017-05-15 13:18:56 -07:00

47 lines
1.3 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 "flutter/shell/testing/test_runner.h"
#include <iostream>
#include "flutter/common/threads.h"
#include "flutter/shell/common/platform_view.h"
#include "flutter/shell/common/shell.h"
#include "flutter/shell/testing/platform_view_test.h"
namespace shell {
TestRunner::TestRunner() : platform_view_(new PlatformViewTest()) {
blink::ViewportMetrics metrics;
metrics.device_pixel_ratio = 3.0;
metrics.physical_width = 2400; // 800 at 3x resolution
metrics.physical_height = 1800; // 600 at 3x resolution
blink::Threads::UI()->PostTask(
[ engine = platform_view_->engine().GetWeakPtr(), metrics ] {
if (engine)
engine->SetViewportMetrics(metrics);
});
}
TestRunner::~TestRunner() = default;
TestRunner& TestRunner::Shared() {
static TestRunner* g_test_runner = nullptr;
if (!g_test_runner)
g_test_runner = new TestRunner();
return *g_test_runner;
}
void TestRunner::Run(const TestDescriptor& test) {
blink::Threads::UI()->PostTask(
[ engine = platform_view_->engine().GetWeakPtr(), test ] {
if (engine)
engine->RunBundleAndSource(std::string(), test.path, test.packages);
});
}
} // namespace shell