OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/gfx/render_text.h" | 5 #include "ui/gfx/render_text.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include <gtk/gtk.h> | 22 #include <gtk/gtk.h> |
23 #endif | 23 #endif |
24 | 24 |
25 namespace gfx { | 25 namespace gfx { |
26 | 26 |
27 namespace { | 27 namespace { |
28 | 28 |
29 // Various weak, LTR, RTL, and Bidi string cases with three characters each. | 29 // Various weak, LTR, RTL, and Bidi string cases with three characters each. |
30 const wchar_t kWeak[] = L" . "; | 30 const wchar_t kWeak[] = L" . "; |
31 const wchar_t kLtr[] = L"abc"; | 31 const wchar_t kLtr[] = L"abc"; |
32 const wchar_t kLtrRtl[] = L"a"L"\x5d0\x5d1"; | 32 const wchar_t kLtrRtl[] = L"a" L"\x5d0\x5d1"; |
33 const wchar_t kLtrRtlLtr[] = L"a"L"\x5d1"L"b"; | 33 const wchar_t kLtrRtlLtr[] = L"a" L"\x5d1" L"b"; |
34 const wchar_t kRtl[] = L"\x5d0\x5d1\x5d2"; | 34 const wchar_t kRtl[] = L"\x5d0\x5d1\x5d2"; |
35 const wchar_t kRtlLtr[] = L"\x5d0\x5d1"L"a"; | 35 const wchar_t kRtlLtr[] = L"\x5d0\x5d1" L"a"; |
36 const wchar_t kRtlLtrRtl[] = L"\x5d0"L"a"L"\x5d1"; | 36 const wchar_t kRtlLtrRtl[] = L"\x5d0" L"a" L"\x5d1"; |
37 | 37 |
38 // Checks whether |range| contains |index|. This is not the same as calling | 38 // Checks whether |range| contains |index|. This is not the same as calling |
39 // |range.Contains(ui::Range(index))| - as that would return true when | 39 // |range.Contains(ui::Range(index))| - as that would return true when |
40 // |index| == |range.end()|. | 40 // |index| == |range.end()|. |
41 bool IndexInRange(const ui::Range& range, size_t index) { | 41 bool IndexInRange(const ui::Range& range, size_t index) { |
42 return index >= range.start() && index < range.end(); | 42 return index >= range.start() && index < range.end(); |
43 } | 43 } |
44 | 44 |
45 base::string16 GetSelectedText(RenderText* render_text) { | 45 base::string16 GetSelectedText(RenderText* render_text) { |
46 return render_text->text().substr(render_text->selection().GetMin(), | 46 return render_text->text().substr(render_text->selection().GetMin(), |
(...skipping 1464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1511 EXPECT_EQ(render_text->display_rect().width() - width - 1, | 1511 EXPECT_EQ(render_text->display_rect().width() - width - 1, |
1512 render_text->GetUpdatedCursorBounds().x()); | 1512 render_text->GetUpdatedCursorBounds().x()); |
1513 | 1513 |
1514 // Reset the application default text direction to LTR. | 1514 // Reset the application default text direction to LTR. |
1515 SetRTL(was_rtl); | 1515 SetRTL(was_rtl); |
1516 EXPECT_EQ(was_rtl, base::i18n::IsRTL()); | 1516 EXPECT_EQ(was_rtl, base::i18n::IsRTL()); |
1517 } | 1517 } |
1518 #endif // !defined(OS_MACOSX) | 1518 #endif // !defined(OS_MACOSX) |
1519 | 1519 |
1520 } // namespace gfx | 1520 } // namespace gfx |
OLD | NEW |