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
6
7#include <memory>
8
9#include "gtest/gtest.h"
10
11namespace flutter::testing {
12
13TEST(OffscreenSurfaceTest, EmptySurfaceIsInvalid) {
14 auto surface = std::make_unique<OffscreenSurface>(nullptr, DlISize());
15 ASSERT_FALSE(surface->IsValid());
16}
17
18TEST(OffscreenSurfaceTest, OnexOneSurfaceIsValid) {
19 auto surface = std::make_unique<OffscreenSurface>(nullptr, DlISize(1, 1));
20 ASSERT_TRUE(surface->IsValid());
21}
22
23TEST(OffscreenSurfaceTest, PaintSurfaceBlack) {
24 auto surface = std::make_unique<OffscreenSurface>(nullptr, DlISize(1, 1));
25
26 DlCanvas* canvas = surface->GetCanvas();
27 canvas->Clear(DlColor::kBlack());
28 canvas->Flush();
29
30 auto raster_data = surface->GetRasterData(false);
31 const uint32_t* actual =
32 reinterpret_cast<const uint32_t*>(raster_data->data());
33
34 // picking black as the color since byte ordering seems to matter.
35 ASSERT_EQ(actual[0], 0xFF000000u);
36}
37
38} // namespace flutter::testing
Developer-facing API for rendering anything within the engine.
Definition dl_canvas.h:32
void Clear(DlColor color)
Definition dl_canvas.h:104
virtual void Flush()=0
VkSurfaceKHR surface
Definition main.cc:65
TEST(NativeAssetsManagerTest, NoAvailableAssets)
impeller::ISize32 DlISize
static constexpr DlColor kBlack()
Definition dl_color.h:69