Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(951)

Side by Side Diff: xfa/fde/css/fde_cssdatatable_unittest.cpp

Issue 1992033002: fgas/ code cleanup. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 PDFium 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 "xfa/fde/css/fde_cssdatatable.h"
6
7 #include "testing/gtest/include/gtest/gtest.h"
8
9 TEST(FDE_ParseCSSColor, HexEncodingParsing) {
10 FX_ARGB color;
11
12 // Length value invalid.
13 EXPECT_FALSE(FDE_ParseCSSColor(L"#000", 3, color));
14 EXPECT_FALSE(FDE_ParseCSSColor(L"#000000", 5, color));
15 EXPECT_FALSE(FDE_ParseCSSColor(L"#000000", 8, color));
16
17 // Invalid characters
18 EXPECT_TRUE(FDE_ParseCSSColor(L"#zxytlm", 7, color));
19 EXPECT_EQ(0, FXARGB_R(color));
20 EXPECT_EQ(0, FXARGB_G(color));
21 EXPECT_EQ(0, FXARGB_B(color));
22
23 EXPECT_TRUE(FDE_ParseCSSColor(L"#000", 4, color));
24 EXPECT_EQ(0, FXARGB_R(color));
25 EXPECT_EQ(0, FXARGB_G(color));
26 EXPECT_EQ(0, FXARGB_B(color));
27
28 EXPECT_TRUE(FDE_ParseCSSColor(L"#FFF", 4, color));
29 EXPECT_EQ(255, FXARGB_R(color));
30 EXPECT_EQ(255, FXARGB_G(color));
31 EXPECT_EQ(255, FXARGB_B(color));
32
33 EXPECT_TRUE(FDE_ParseCSSColor(L"#F0F0F0", 7, color));
34 EXPECT_EQ(240, FXARGB_R(color));
35 EXPECT_EQ(240, FXARGB_G(color));
36 EXPECT_EQ(240, FXARGB_B(color));
37
38 // Upper and lower case characters.
39 EXPECT_TRUE(FDE_ParseCSSColor(L"#1b2F3c", 7, color));
40 EXPECT_EQ(27, FXARGB_R(color));
41 EXPECT_EQ(47, FXARGB_G(color));
42 EXPECT_EQ(60, FXARGB_B(color));
43 }
44
45 TEST(FDE_ParseCSSColor, RGBEncodingParsing) {
46 FX_ARGB color;
47
48 // Invalid input for rgb() syntax.
49 EXPECT_FALSE(FDE_ParseCSSColor(L"blahblahblah", 11, color));
50
51 EXPECT_TRUE(FDE_ParseCSSColor(L"rgb(0, 0, 0)", 12, color));
52 EXPECT_EQ(0, FXARGB_R(color));
53 EXPECT_EQ(0, FXARGB_G(color));
54 EXPECT_EQ(0, FXARGB_B(color));
55
56 EXPECT_TRUE(FDE_ParseCSSColor(L"rgb(128,255,48)", 15, color));
57 EXPECT_EQ(128, FXARGB_R(color));
58 EXPECT_EQ(255, FXARGB_G(color));
59 EXPECT_EQ(48, FXARGB_B(color));
60 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698