diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-08-08 13:23:24 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-08-08 17:37:54 +0000 |
commit | 9f0e85ac36826e39a242f8039c2b2c333ee99f4f (patch) | |
tree | c93f2a9322968f7723a4b3da5ea5e4cb7b79b075 /xfa/fde/css/cfde_cssvaluelistparser_unittest.cpp | |
parent | 78fc9aa402409f3fcd8dc1f458e67798cb3b483e (diff) | |
download | pdfium-9f0e85ac36826e39a242f8039c2b2c333ee99f4f.tar.xz |
Move CSS code to core
The xfa/fde/css code has no other links into xfa/. This CL moves the css
code to core/fxcrt/css and sets to only build when pdf_enable_xfa is
enabled.
Change-Id: Iefd208e1f83a28b80b567c574e841e87bce310be
Reviewed-on: https://pdfium-review.googlesource.com/9251
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa/fde/css/cfde_cssvaluelistparser_unittest.cpp')
-rw-r--r-- | xfa/fde/css/cfde_cssvaluelistparser_unittest.cpp | 143 |
1 files changed, 0 insertions, 143 deletions
diff --git a/xfa/fde/css/cfde_cssvaluelistparser_unittest.cpp b/xfa/fde/css/cfde_cssvaluelistparser_unittest.cpp deleted file mode 100644 index 53a0657e12..0000000000 --- a/xfa/fde/css/cfde_cssvaluelistparser_unittest.cpp +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright 2017 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#include "xfa/fde/css/cfde_cssvaluelistparser.h" - -#include "testing/gtest/include/gtest/gtest.h" -#include "testing/test_support.h" -#include "third_party/base/ptr_util.h" - -TEST(CFDE_CSSValueListParserTest, rgb_short) { - FDE_CSSPrimitiveType type; - const wchar_t* start; - int32_t len; - - auto parser = pdfium::MakeUnique<CFDE_CSSValueListParser>(L"#abc", 4, L' '); - EXPECT_TRUE(parser->NextValue(type, start, len)); - EXPECT_EQ(FDE_CSSPrimitiveType::RGB, type); - EXPECT_EQ(L"#abc", CFX_WideString(start, len)); - EXPECT_FALSE(parser->NextValue(type, start, len)); - - parser = pdfium::MakeUnique<CFDE_CSSValueListParser>(L"#abcdef", 7, L' '); - EXPECT_TRUE(parser->NextValue(type, start, len)); - EXPECT_EQ(FDE_CSSPrimitiveType::RGB, type); - EXPECT_EQ(L"#abcdef", CFX_WideString(start, len)); - EXPECT_FALSE(parser->NextValue(type, start, len)); - - parser = - pdfium::MakeUnique<CFDE_CSSValueListParser>(L"rgb(1, 255, 4)", 14, L' '); - EXPECT_TRUE(parser->NextValue(type, start, len)); - EXPECT_EQ(FDE_CSSPrimitiveType::RGB, type); - EXPECT_EQ(L"rgb(1, 255, 4)", CFX_WideString(start, len)); - - parser = - pdfium::MakeUnique<CFDE_CSSValueListParser>(L"#abcdefghij", 11, L' '); - EXPECT_TRUE(parser->NextValue(type, start, len)); - EXPECT_EQ(FDE_CSSPrimitiveType::Unknown, type); - EXPECT_EQ(L"#abcdefghij", CFX_WideString(start, len)); - EXPECT_FALSE(parser->NextValue(type, start, len)); -} - -TEST(CFDE_CSSValueListParserTest, number_parsing) { - FDE_CSSPrimitiveType type; - const wchar_t* start; - int32_t len; - - auto parser = pdfium::MakeUnique<CFDE_CSSValueListParser>(L"1234", 4, L' '); - EXPECT_TRUE(parser->NextValue(type, start, len)); - EXPECT_EQ(FDE_CSSPrimitiveType::Number, type); - EXPECT_EQ(L"1234", CFX_WideString(start, len)); - - parser = pdfium::MakeUnique<CFDE_CSSValueListParser>(L"-1234", 5, L' '); - EXPECT_TRUE(parser->NextValue(type, start, len)); - EXPECT_EQ(FDE_CSSPrimitiveType::Number, type); - EXPECT_EQ(L"-1234", CFX_WideString(start, len)); - - parser = pdfium::MakeUnique<CFDE_CSSValueListParser>(L"+1234", 5, L' '); - EXPECT_TRUE(parser->NextValue(type, start, len)); - EXPECT_EQ(FDE_CSSPrimitiveType::Number, type); - EXPECT_EQ(L"+1234", CFX_WideString(start, len)); - - parser = pdfium::MakeUnique<CFDE_CSSValueListParser>(L".1234", 5, L' '); - EXPECT_TRUE(parser->NextValue(type, start, len)); - EXPECT_EQ(FDE_CSSPrimitiveType::Number, type); - EXPECT_EQ(L".1234", CFX_WideString(start, len)); - - parser = pdfium::MakeUnique<CFDE_CSSValueListParser>(L"4321.1234", 9, L' '); - EXPECT_TRUE(parser->NextValue(type, start, len)); - EXPECT_EQ(FDE_CSSPrimitiveType::Number, type); - EXPECT_EQ(L"4321.1234", CFX_WideString(start, len)); - - // TODO(dsinclair): These should probably fail but currently don't. - parser = pdfium::MakeUnique<CFDE_CSSValueListParser>(L"4321.12.34", 10, L' '); - EXPECT_TRUE(parser->NextValue(type, start, len)); - EXPECT_EQ(FDE_CSSPrimitiveType::Number, type); - EXPECT_EQ(L"4321.12.34", CFX_WideString(start, len)); - - parser = pdfium::MakeUnique<CFDE_CSSValueListParser>(L"43a1.12.34", 10, L' '); - EXPECT_TRUE(parser->NextValue(type, start, len)); - EXPECT_EQ(FDE_CSSPrimitiveType::Number, type); - EXPECT_EQ(L"43a1.12.34", CFX_WideString(start, len)); -} - -TEST(CFDE_CSSValueListParserTest, string_parsing) { - FDE_CSSPrimitiveType type; - const wchar_t* start; - int32_t len; - - auto parser = - pdfium::MakeUnique<CFDE_CSSValueListParser>(L"'string'", 8, L' '); - EXPECT_TRUE(parser->NextValue(type, start, len)); - EXPECT_EQ(FDE_CSSPrimitiveType::String, type); - EXPECT_EQ(L"string", CFX_WideString(start, len)); - - parser = pdfium::MakeUnique<CFDE_CSSValueListParser>(L"\"another string\"", - 16, L' '); - EXPECT_TRUE(parser->NextValue(type, start, len)); - EXPECT_EQ(FDE_CSSPrimitiveType::String, type); - EXPECT_EQ(L"another string", CFX_WideString(start, len)); - - parser = pdfium::MakeUnique<CFDE_CSSValueListParser>(L"standalone", 10, L' '); - EXPECT_TRUE(parser->NextValue(type, start, len)); - EXPECT_EQ(FDE_CSSPrimitiveType::String, type); - EXPECT_EQ(L"standalone", CFX_WideString(start, len)); -} - -TEST(CFDE_CSSValueListParserTest, multiparsing) { - FDE_CSSPrimitiveType type; - const wchar_t* start; - int32_t len; - - auto parser = - pdfium::MakeUnique<CFDE_CSSValueListParser>(L"1, 2, 3", 7, L','); - EXPECT_TRUE(parser->NextValue(type, start, len)); - EXPECT_EQ(FDE_CSSPrimitiveType::Number, type); - EXPECT_EQ(L"1", CFX_WideString(start, len)); - - EXPECT_TRUE(parser->NextValue(type, start, len)); - EXPECT_EQ(FDE_CSSPrimitiveType::Number, type); - EXPECT_EQ(L"2", CFX_WideString(start, len)); - - EXPECT_TRUE(parser->NextValue(type, start, len)); - EXPECT_EQ(FDE_CSSPrimitiveType::Number, type); - EXPECT_EQ(L"3", CFX_WideString(start, len)); - - EXPECT_FALSE(parser->NextValue(type, start, len)); - - parser = pdfium::MakeUnique<CFDE_CSSValueListParser>( - L"'str', rgb(1, 2, 3), 4", 22, L','); - EXPECT_TRUE(parser->NextValue(type, start, len)); - EXPECT_EQ(FDE_CSSPrimitiveType::String, type); - EXPECT_EQ(L"str", CFX_WideString(start, len)); - - EXPECT_TRUE(parser->NextValue(type, start, len)); - EXPECT_EQ(FDE_CSSPrimitiveType::RGB, type); - EXPECT_EQ(L"rgb(1, 2, 3)", CFX_WideString(start, len)); - - EXPECT_TRUE(parser->NextValue(type, start, len)); - EXPECT_EQ(FDE_CSSPrimitiveType::Number, type); - EXPECT_EQ(L"4", CFX_WideString(start, len)); -} |