Flutter Engine
The Flutter Engine
dl_color_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/display_list/dl_color.h"
6#include "flutter/testing/testing.h"
7
9
10namespace flutter {
11namespace testing {
12
13static void arraysEqual(const uint32_t* ints,
14 const DlColor* colors,
15 int count) {
16 for (int i = 0; i < count; i++) {
17 EXPECT_TRUE(ints[i] == colors[i].argb());
18 }
19}
20
21TEST(DisplayListColor, ArrayInterchangeableWithUint32) {
22 uint32_t ints[5] = {
23 0xFF000000, //
24 0xFFFF0000, //
25 0xFF00FF00, //
26 0xFF0000FF, //
27 0xF1F2F3F4,
28 };
29 DlColor colors[5] = {
30 DlColor::kBlack(), //
31 DlColor::kRed(), //
32 DlColor::kGreen(), //
33 DlColor::kBlue(), //
34 DlColor(0xF1F2F3F4),
35 };
36 arraysEqual(ints, colors, 5);
37 arraysEqual(reinterpret_cast<const uint32_t*>(colors),
38 reinterpret_cast<const DlColor*>(ints), 5);
39}
40
41TEST(DisplayListColor, DlColorDirectlyComparesToSkColor) {
42 EXPECT_EQ(DlColor::kBlack(), SK_ColorBLACK);
43 EXPECT_EQ(DlColor::kRed(), SK_ColorRED);
44 EXPECT_EQ(DlColor::kGreen(), SK_ColorGREEN);
45 EXPECT_EQ(DlColor::kBlue(), SK_ColorBLUE);
46}
47
48} // namespace testing
49} // namespace flutter
int count
Definition: FontMgrTest.cpp:50
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
constexpr SkColor SK_ColorGREEN
Definition: SkColor.h:131
PODArray< SkColor > colors
Definition: SkRecords.h:276
static void arraysEqual(const uint32_t *ints, const DlColor *colors, int count)
TEST(DisplayListComplexity, EmptyDisplayList)
flutter::DlColor DlColor
static constexpr DlColor kBlue()
Definition: dl_color.h:26
static constexpr DlColor kBlack()
Definition: dl_color.h:22
static constexpr DlColor kRed()
Definition: dl_color.h:24
static constexpr DlColor kGreen()
Definition: dl_color.h:25
#define EXPECT_TRUE(handle)
Definition: unit_test.h:678