Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
offscreen_surface_unittests.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "flutter/flow/layers/offscreen_surface.h"
6
7#include <memory>
8
9#include "gtest/gtest.h"
13
14namespace flutter::testing {
15
16TEST(OffscreenSurfaceTest, EmptySurfaceIsInvalid) {
17 auto surface =
18 std::make_unique<OffscreenSurface>(nullptr, SkISize::MakeEmpty());
19 ASSERT_FALSE(surface->IsValid());
20}
21
22TEST(OffscreenSurfaceTest, OnexOneSurfaceIsValid) {
23 auto surface =
24 std::make_unique<OffscreenSurface>(nullptr, SkISize::Make(1, 1));
25 ASSERT_TRUE(surface->IsValid());
26}
27
28TEST(OffscreenSurfaceTest, PaintSurfaceBlack) {
29 auto surface =
30 std::make_unique<OffscreenSurface>(nullptr, SkISize::Make(1, 1));
31
32 DlCanvas* canvas = surface->GetCanvas();
33 canvas->Clear(DlColor::kBlack());
34 canvas->Flush();
35
36 auto raster_data = surface->GetRasterData(false);
37 const uint32_t* actual =
38 reinterpret_cast<const uint32_t*>(raster_data->data());
39
40 // picking black as the color since byte ordering seems to matter.
41 ASSERT_EQ(actual[0], 0xFF000000u);
42}
43
44} // namespace flutter::testing
#define TEST(S, s, D, expected)
Developer-facing API for rendering anything within the engine.
Definition dl_canvas.h:37
void Clear(DlColor color)
Definition dl_canvas.h:131
virtual void Flush()=0
VkSurfaceKHR surface
Definition main.cc:49
static constexpr SkISize MakeEmpty()
Definition SkSize.h:22
static constexpr SkISize Make(int32_t w, int32_t h)
Definition SkSize.h:20
static constexpr DlColor kBlack()
Definition dl_color.h:22