Add toplevel trace event to MessagePumpLibevent::OnLibeventNotification
[chromium-blink-merge.git] / ash / popup_message_unittest.cc
blob374e0aa5d794e9be77dfaea1157e257766f38593
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.
5 #include "ash/popup_message.h"
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"
12 namespace ash {
14 typedef test::AshTestBase PopupMessageTest;
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);
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);
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());
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()));
48 message.Close();
49 widget->Close();
52 } // namespace ash