Commit fc77ffea authored by Chong Gu's avatar Chong Gu Committed by Commit Bot

[Fuchsia] Allow Fuchsia tests to run with scenic ozone platform

Keep bounds we are given instead of only keeping the size. Allows tests requiring this information to pass.
Create allow_null_view_token_for_test, which allows tests to create a view themselves.

Change-Id: Icab59c3d622537d5651c128a6c9572c667187338
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2462241Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarWez <wez@chromium.org>
Reviewed-by: default avatarBrian Sheedy <bsheedy@chromium.org>
Commit-Queue: Chong Gu <chonggu@google.com>
Auto-Submit: Chong Gu <chonggu@google.com>
Cr-Commit-Position: refs/heads/master@{#820310}
parent 10b08559
......@@ -14138,7 +14138,6 @@
},
{
"args": [
"--child-arg=--ozone-platform=headless",
"--runner-logs-dir=${ISOLATED_OUTDIR}/runner_logs"
],
"merge": {
......@@ -14449,7 +14448,6 @@
},
{
"args": [
"--child-arg=--ozone-platform=headless",
"--runner-logs-dir=${ISOLATED_OUTDIR}/runner_logs"
],
"merge": {
......@@ -15046,7 +15044,6 @@
},
{
"args": [
"--child-arg=--ozone-platform=headless",
"--runner-logs-dir=${ISOLATED_OUTDIR}/runner_logs"
],
"merge": {
......@@ -15360,7 +15357,6 @@
},
{
"args": [
"--child-arg=--ozone-platform=headless",
"--runner-logs-dir=${ISOLATED_OUTDIR}/runner_logs"
],
"merge": {
......@@ -15671,7 +15667,6 @@
},
{
"args": [
"--child-arg=--ozone-platform=headless",
"--runner-logs-dir=${ISOLATED_OUTDIR}/runner_logs"
],
"merge": {
......@@ -16268,7 +16263,6 @@
},
{
"args": [
"--child-arg=--ozone-platform=headless",
"--runner-logs-dir=${ISOLATED_OUTDIR}/runner_logs"
],
"merge": {
......@@ -16580,7 +16574,6 @@
},
{
"args": [
"--child-arg=--ozone-platform=headless",
"--runner-logs-dir=${ISOLATED_OUTDIR}/runner_logs"
],
"merge": {
......@@ -16877,7 +16870,6 @@
},
{
"args": [
"--child-arg=--ozone-platform=headless",
"--runner-logs-dir=${ISOLATED_OUTDIR}/runner_logs"
],
"merge": {
......@@ -17447,7 +17439,6 @@
},
{
"args": [
"--child-arg=--ozone-platform=headless",
"--runner-logs-dir=${ISOLATED_OUTDIR}/runner_logs"
],
"merge": {
......@@ -17747,7 +17738,6 @@
},
{
"args": [
"--child-arg=--ozone-platform=headless",
"--runner-logs-dir=${ISOLATED_OUTDIR}/runner_logs"
],
"merge": {
......@@ -18044,7 +18034,6 @@
},
{
"args": [
"--child-arg=--ozone-platform=headless",
"--runner-logs-dir=${ISOLATED_OUTDIR}/runner_logs"
],
"merge": {
......@@ -18614,7 +18603,6 @@
},
{
"args": [
"--child-arg=--ozone-platform=headless",
"--runner-logs-dir=${ISOLATED_OUTDIR}/runner_logs"
],
"merge": {
......@@ -1841,7 +1841,6 @@
},
{
"args": [
"--child-arg=--ozone-platform=headless",
"--runner-logs-dir=${ISOLATED_OUTDIR}/runner_logs"
],
"merge": {
......@@ -2108,7 +2107,6 @@
},
{
"args": [
"--child-arg=--ozone-platform=headless",
"--runner-logs-dir=${ISOLATED_OUTDIR}/runner_logs"
],
"merge": {
......@@ -2705,7 +2703,6 @@
},
{
"args": [
"--child-arg=--ozone-platform=headless",
"--runner-logs-dir=${ISOLATED_OUTDIR}/runner_logs"
],
"merge": {
......@@ -2995,7 +2992,6 @@
},
{
"args": [
"--child-arg=--ozone-platform=headless",
"--runner-logs-dir=${ISOLATED_OUTDIR}/runner_logs"
],
"merge": {
......@@ -3292,7 +3288,6 @@
},
{
"args": [
"--child-arg=--ozone-platform=headless",
"--runner-logs-dir=${ISOLATED_OUTDIR}/runner_logs"
],
"merge": {
......@@ -3862,7 +3857,6 @@
},
{
"args": [
"--child-arg=--ozone-platform=headless",
"--runner-logs-dir=${ISOLATED_OUTDIR}/runner_logs"
],
"merge": {
......
......@@ -1391,10 +1391,6 @@
},
'aura_unittests': {
'mixins': ['fuchsia_runner_logs'],
'args': [
# http://crbug.com/865172
'--child-arg=--ozone-platform=headless',
],
},
'base_unittests': {
'mixins': ['fuchsia_runner_logs'],
......@@ -1449,10 +1445,6 @@
},
'compositor_unittests': {
'mixins': ['fuchsia_runner_logs'],
'args': [
# http://crbug.com/865172
'--child-arg=--ozone-platform=headless',
],
},
'content_unittests': {
'mixins': ['fuchsia_runner_logs'],
......@@ -1547,10 +1539,6 @@
},
'snapshot_unittests': {
'mixins': ['fuchsia_runner_logs'],
'args': [
# http://crbug.com/865172
'--child-arg=--ozone-platform=headless',
],
},
'sql_unittests': {
'mixins': ['fuchsia_runner_logs'],
......
......@@ -46,6 +46,10 @@
#include "ui/events/ozone/events_ozone.h"
#endif
#if defined(OS_FUCHSIA)
#include "ui/platform_window/platform_window_init_properties.h"
#endif
namespace aura {
namespace test {
namespace {
......@@ -67,6 +71,10 @@ AuraTestHelper::AuraTestHelper(ui::ContextFactory* context_factory,
ui::DisableNativeUiEventDispatchForTest();
#endif
#if defined(OS_FUCHSIA)
ui::PlatformWindowInitProperties::allow_null_view_token_for_test = true;
#endif
ui::InitializeInputMethodForTesting();
ui::test::EventGeneratorDelegate::SetFactoryFunction(
......
......@@ -19,11 +19,6 @@
#include "ui/gfx/native_widget_types.h"
#include "ui/platform_window/platform_window_init_properties.h"
#if defined(OS_FUCHSIA)
#include "ui/ozone/public/ozone_platform.h" // nogncheck
#include "ui/platform_window/fuchsia/initialize_presenter_api_view.h"
#endif
namespace aura {
namespace {
......@@ -51,13 +46,6 @@ WindowTreeHost* TestScreen::CreateHostForPrimaryDisplay() {
DCHECK(!host_);
ui::PlatformWindowInitProperties properties(
gfx::Rect(GetPrimaryDisplay().GetSizeInPixel()));
#if defined(OS_FUCHSIA)
if (ui::OzonePlatform::GetInstance()
->GetPlatformProperties()
.needs_view_token) {
ui::fuchsia::InitializeViewTokenAndPresentView(&properties);
}
#endif
host_ = WindowTreeHost::Create(std::move(properties)).release();
// Some tests don't correctly manage window focus/activation states.
// Makes sure InputMethod is default focused so that IME basics can work.
......
......@@ -67,7 +67,11 @@ TestCompositorHostOzone::TestCompositorHostOzone(
context_factory,
base::ThreadTaskRunnerHandle::Get(),
false /* enable_pixel_canvas */),
window_delegate_(std::make_unique<StubPlatformWindowDelegate>()) {}
window_delegate_(std::make_unique<StubPlatformWindowDelegate>()) {
#if defined(OS_FUCHSIA)
ui::PlatformWindowInitProperties::allow_null_view_token_for_test = true;
#endif
}
TestCompositorHostOzone::~TestCompositorHostOzone() {
// |window_| should be destroyed earlier than |window_delegate_| as it refers
......
......@@ -15,6 +15,7 @@
#include "base/no_destructor.h"
#include "base/notreached.h"
#include "base/task/current_thread.h"
#include "build/build_config.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "ui/base/cursor/cursor_factory.h"
#include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h"
......@@ -41,6 +42,10 @@
#include "ui/ozone/public/system_input_injector.h"
#include "ui/platform_window/platform_window_init_properties.h"
#if defined(OS_FUCHSIA)
#include "ui/platform_window/fuchsia/initialize_presenter_api_view.h"
#endif
namespace ui {
namespace {
......@@ -89,9 +94,11 @@ class OzonePlatformScenic : public OzonePlatform,
PlatformWindowDelegate* delegate,
PlatformWindowInitProperties properties) override {
BindInMainProcessIfNecessary();
// Allow tests to create a view themselves.
if (!properties.view_token.value) {
NOTREACHED();
return nullptr;
CHECK(properties.allow_null_view_token_for_test);
ui::fuchsia::InitializeViewTokenAndPresentView(&properties);
}
return std::make_unique<ScenicWindow>(window_manager_.get(), delegate,
std::move(properties));
......
......@@ -37,7 +37,7 @@ ScenicWindow::ScenicWindow(ScenicWindowManager* window_manager,
node_(&scenic_session_),
input_node_(&scenic_session_),
render_node_(&scenic_session_),
size_pixels_(properties.bounds.size()) {
bounds_(properties.bounds) {
scenic_session_.set_error_handler(
fit::bind_member(this, &ScenicWindow::OnScenicError));
scenic_session_.set_event_handler(
......@@ -84,12 +84,12 @@ void ScenicWindow::AttachSurfaceView(
}
gfx::Rect ScenicWindow::GetBounds() {
return gfx::Rect(size_pixels_);
return bounds_;
}
void ScenicWindow::SetBounds(const gfx::Rect& bounds) {
// View dimensions are controlled by the containing view, it's not possible to
// set them here.
// This path should only be reached in tests.
bounds_ = bounds;
}
void ScenicWindow::SetTitle(const base::string16& title) {
......@@ -215,13 +215,12 @@ void ScenicWindow::SizeConstraintsChanged() {
void ScenicWindow::UpdateSize() {
gfx::SizeF scaled = ScaleSize(size_dips_, device_pixel_ratio_);
size_pixels_ = gfx::Size(ceilf(scaled.width()), ceilf(scaled.height()));
gfx::Rect size_rect(size_pixels_);
bounds_ = gfx::Rect(gfx::Size(ceilf(scaled.width()), ceilf(scaled.height())));
// Update this window's Screen's dimensions to match the new size.
ScenicScreen* screen = manager_->screen();
if (screen)
screen->OnWindowBoundsChanged(window_id_, size_rect);
screen->OnWindowBoundsChanged(window_id_, bounds_);
// Translate the node by half of the view dimensions to put it in the center
// of the view.
......@@ -243,7 +242,7 @@ void ScenicWindow::UpdateSize() {
/*requested_prediction_span=*/0,
[](fuchsia::scenic::scheduling::FuturePresentationTimes info) {});
delegate_->OnBoundsChanged(size_rect);
delegate_->OnBoundsChanged(bounds_);
}
void ScenicWindow::OnScenicError(zx_status_t status) {
......
......@@ -132,7 +132,7 @@ class COMPONENT_EXPORT(OZONE) ScenicWindow
// |PlatformWindowInitProperties.bounds.size()| value until Show() is called
// for the first time. After that the size is set to the size of the
// corresponding Scenic view.
gfx::Size size_pixels_;
gfx::Rect bounds_;
bool visible_ = false;
......
......@@ -17,4 +17,8 @@ PlatformWindowInitProperties::PlatformWindowInitProperties(
PlatformWindowInitProperties::~PlatformWindowInitProperties() = default;
#if defined(OS_FUCHSIA)
bool PlatformWindowInitProperties::allow_null_view_token_for_test = false;
#endif
} // namespace ui
......@@ -71,6 +71,7 @@ struct COMPONENT_EXPORT(PLATFORM_WINDOW) PlatformWindowInitProperties {
#if defined(OS_FUCHSIA)
fuchsia::ui::views::ViewToken view_token;
scenic::ViewRefPair view_ref_pair;
static bool allow_null_view_token_for_test;
#endif
bool activatable = true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment