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

Side by Side Diff: ash/popup_message_unittest.cc

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

Powered by Google App Engine
This is Rietveld 408576698