Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
cfgas_txtbreak_unittest.cpp
Go to the documentation of this file.
1
// Copyright 2018 The PDFium Authors
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/fgas/layout/cfgas_txtbreak.h"
6
7
#
include
<
memory
>
8
#
include
<
utility
>
9
10
#
include
"core/fxcrt/fx_codepage.h"
11
#
include
"core/fxge/cfx_font.h"
12
#
include
"testing/gtest/include/gtest/gtest.h"
13
#
include
"xfa/fgas/font/cfgas_fontmgr.h"
14
#
include
"xfa/fgas/font/cfgas_gefont.h"
15
#
include
"xfa/fgas/layout/cfgas_char.h"
16
17
class
CFGAS_TxtBreakTest
:
public
testing
::
Test
{
18
public
:
19
void
SetUp
()
override
{
20
const
wchar_t
kFontFamily[] = L"Arimo Bold";
21
font_ = CFGAS_GEFont::LoadFont(kFontFamily, 0, FX_CodePage::kDefANSI);
22
ASSERT_TRUE(font_);
23
}
24
25
std
::
unique_ptr
<
CFGAS_TxtBreak
>
CreateBreak
() {
26
auto
txt_break =
std
::make_unique<CFGAS_TxtBreak>();
27
txt_break->SetFont(font_);
28
return
txt_break;
29
}
30
31
private
:
32
RetainPtr
<CFGAS_GEFont> font_;
33
};
34
35
TEST_F
(
CFGAS_TxtBreakTest
,
BidiLine
) {
36
auto
txt_break = CreateBreak();
37
txt_break->SetLineBreakTolerance(1);
38
txt_break->SetFontSize(12);
39
40
// SAFETY: known fixed-length string.
41
WideString
input =
42
WideString
::
FromUTF8
(
UNSAFE_BUFFERS
(ByteStringView(
"\xa\x0\xa\xa"
, 4)));
43
for
(
wchar_t
ch : input)
44
txt_break->AppendChar(ch);
45
46
std::vector<CFGAS_Char> chars =
47
txt_break->GetCurrentLineForTesting()->m_LineChars;
48
CFGAS_Char::BidiLine(&chars, chars.size());
49
EXPECT_EQ(3u, chars.size());
50
}
TEST_F
TEST_F(CFGAS_TxtBreakTest, BidiLine)
Definition
cfgas_txtbreak_unittest.cpp:35
CFGAS_TxtBreakTest
Definition
cfgas_txtbreak_unittest.cpp:17
CFGAS_TxtBreakTest::SetUp
void SetUp() override
Definition
cfgas_txtbreak_unittest.cpp:19
CFGAS_TxtBreakTest::CreateBreak
std::unique_ptr< CFGAS_TxtBreak > CreateBreak()
Definition
cfgas_txtbreak_unittest.cpp:25
fxcrt::RetainPtr
Definition
retain_ptr.h:28
fxcrt::WideString::FromUTF8
static WideString FromUTF8(ByteStringView str)
Definition
widestring.cpp:738
UNSAFE_BUFFERS
#define UNSAFE_BUFFERS(...)
Definition
compiler_specific.h:95
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
WideString
fxcrt::WideString WideString
Definition
widestring.h:207
qtwebengine
src
3rdparty
chromium
third_party
pdfium
xfa
fgas
layout
cfgas_txtbreak_unittest.cpp
Generated on
for Qt by
1.18.0