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

Side by Side Diff: ash/popup_message_unittest.cc

Issue 1026943002: Add the layout test case of ash/popup_message. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: view by id Created 5 years, 9 months 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 | « ash/popup_message.cc ('k') | no next file » | 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 2015 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 "ash/popup_message.h"
6
7 #include "ash/test/ash_test_base.h"
8 #include "base/strings/utf_string_conversions.h"
9 #include "ui/views/controls/label.h"
10 #include "ui/views/widget/widget.h"
11
12 namespace ash {
13
14 typedef test::AshTestBase PopupMessageTest;
15
16 // Verifies the layout of the popup, especially it does not crop the caption and
17 // message text. See http://crbug.com/468494.
18 TEST_F(PopupMessageTest, Layout) {
19 views::Widget* widget =
20 views::Widget::CreateWindowWithBounds(nullptr, gfx::Rect(0, 0, 100, 100));
21 PopupMessage message(base::ASCIIToUTF16("caption text"),
22 base::ASCIIToUTF16(
23 "Message text, which will be usually longer than "
24 "the caption, so that it's wrapped at some width"),
25 PopupMessage::ICON_WARNING,
26 widget->GetContentsView() /* anchor */,
27 views::BubbleBorder::TOP_LEFT, gfx::Size(), 10);
28
29 views::View* contents_view = message.widget_->GetContentsView();
30 views::View* caption_label =
31 contents_view->GetViewByID(PopupMessage::kCaptionLabelID);
32 views::View* message_label =
33 contents_view->GetViewByID(PopupMessage::kMessageLabelID);
34 ASSERT_TRUE(caption_label);
35 ASSERT_TRUE(message_label);
36
37 // The bubble should have enough heights to show both of the labels.
38 EXPECT_GE(contents_view->height(),
39 caption_label->height() + message_label->height());
40
41 // The labels are not cropped -- the assigned height has enough height to show
42 // the full text.
43 EXPECT_GE(caption_label->height(),
44 caption_label->GetHeightForWidth(caption_label->width()));
45 EXPECT_GE(message_label->height(),
46 message_label->GetHeightForWidth(message_label->width()));
47
48 message.Close();
49 widget->Close();
50 }
51
52 } // namespace ash
OLDNEW
« no previous file with comments | « ash/popup_message.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698