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

Side by Side Diff: chrome/browser/ui/views/download/download_item_view_unittest.cc

Issue 2556573002: Fix SizeLabelToMinWidth() function such that no unnecessary space (Closed)
Patch Set: change to ViewsTestBase Created 4 years 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
« no previous file with comments | « chrome/browser/ui/views/download/download_item_view.cc ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium 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 "chrome/browser/ui/views/download/download_item_view.h"
6
7 #include "base/strings/utf_string_conversions.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/views/controls/label.h"
10 #include "ui/views/test/views_test_base.h"
11
12 using DownloadItemViewDangerousDownloadLabelTest = views::ViewsTestBase;
13
14 TEST_F(DownloadItemViewDangerousDownloadLabelTest, AdjustTextAndGetSize) {
15 // For very short label that can fit in a single line, no need to do any
16 // adjustment, return it directly.
17 base::string16 label_text = base::ASCIIToUTF16("short");
18 views::Label label(label_text);
19 label.SetMultiLine(true);
20 DownloadItemView::AdjustTextAndGetSize(&label);
21 EXPECT_EQ(label_text, label.text());
22
23 // When we have multiple linebreaks that result in the same minimum width, we
24 // should place as much text as possible on the first line.
25 label_text = base::ASCIIToUTF16(
26 "aaaa aaaa aaaa aaaa aaaa aaaa bb aaaa aaaa aaaa aaaa aaaa aaaa");
27 base::string16 expected_text = base::ASCIIToUTF16(
28 "aaaa aaaa aaaa aaaa aaaa aaaa bb\n"
29 "aaaa aaaa aaaa aaaa aaaa aaaa");
30 label.SetText(label_text);
31 DownloadItemView::AdjustTextAndGetSize(&label);
32 EXPECT_EQ(expected_text, label.text());
33
34 // If the label is a single word and extremely long, we should not break it
35 // into 2 lines.
36 label_text = base::ASCIIToUTF16(
37 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
38 label.SetText(label_text);
39 DownloadItemView::AdjustTextAndGetSize(&label);
40 EXPECT_EQ(label_text, label.text());
41 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/download/download_item_view.cc ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698