| OLD | NEW |
| (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/common/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 using PopupMessageTest = test::AshTestBase; | |
| 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 = views::Widget::CreateWindowWithContextAndBounds( | |
| 20 nullptr, CurrentContext(), gfx::Rect(0, 0, 100, 100)); | |
| 21 PopupMessage message( | |
| 22 base::ASCIIToUTF16("caption text"), | |
| 23 base::ASCIIToUTF16("Message text, which will be usually longer than " | |
| 24 "the caption, so that it's wrapped at some width"), | |
| 25 PopupMessage::ICON_WARNING, widget->GetContentsView() /* anchor */, | |
| 26 views::BubbleBorder::TOP_LEFT, gfx::Size(), 10); | |
| 27 | |
| 28 views::View* contents_view = message.widget_->GetContentsView(); | |
| 29 views::View* caption_label = | |
| 30 contents_view->GetViewByID(PopupMessage::kCaptionLabelID); | |
| 31 views::View* message_label = | |
| 32 contents_view->GetViewByID(PopupMessage::kMessageLabelID); | |
| 33 ASSERT_TRUE(caption_label); | |
| 34 ASSERT_TRUE(message_label); | |
| 35 | |
| 36 // The bubble should have enough heights to show both of the labels. | |
| 37 EXPECT_GE(contents_view->height(), | |
| 38 caption_label->height() + message_label->height()); | |
| 39 | |
| 40 // The labels are not cropped -- the assigned height has enough height to show | |
| 41 // the full text. | |
| 42 EXPECT_GE(caption_label->height(), | |
| 43 caption_label->GetHeightForWidth(caption_label->width())); | |
| 44 EXPECT_GE(message_label->height(), | |
| 45 message_label->GetHeightForWidth(message_label->width())); | |
| 46 | |
| 47 message.Close(); | |
| 48 widget->Close(); | |
| 49 } | |
| 50 | |
| 51 } // namespace ash | |
| OLD | NEW |