Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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
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
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
36 auto txt_break = CreateBreak();
37 txt_break->SetLineBreakTolerance(1);
38 txt_break->SetFontSize(12);
39
40 WideString input = WideString::FromUTF8(ByteStringView("\xa\x0\xa\xa", 4));
41 for (wchar_t ch : input)
42 txt_break->AppendChar(ch);
43
44 std::vector<CFGAS_Char> chars =
45 txt_break->GetCurrentLineForTesting()->m_LineChars;
46 CFGAS_Char::BidiLine(&chars, chars.size());
47 EXPECT_EQ(3u, chars.size());
48}
TEST_F(CFGAS_TxtBreakTest, BidiLine)
std::unique_ptr< CFGAS_TxtBreak > CreateBreak()
static WideString FromUTF8(ByteStringView str)