| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2013 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 #import <Cocoa/Cocoa.h> |
| 6 |
| 7 #include "base/memory/scoped_nsobject.h" |
| 8 #include "base/utf_string_conversions.h" |
| 9 #import "chrome/browser/ui/cocoa/validation_message_bubble_controller.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 |
| 12 namespace { |
| 13 |
| 14 static NSView* constructView(const char* main_text, const char* sub_text) { |
| 15 return [ValidationMessageBubbleController |
| 16 constructContentView:UTF8ToUTF16(main_text) |
| 17 subText:UTF8ToUTF16(sub_text)]; |
| 18 } |
| 19 |
| 20 TEST(ValidationMessageBubbleControllerTest, FrameSize) { |
| 21 NSRect shortMainNoSubFrame = [constructView("abc", "") frame]; |
| 22 EXPECT_GE(NSWidth(shortMainNoSubFrame), 40); |
| 23 EXPECT_GT(NSHeight(shortMainNoSubFrame), 0); |
| 24 |
| 25 NSRect longMainNoSubFrame = [constructView( |
| 26 "very very very long text which overlfows the maximum window width. " |
| 27 "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod" |
| 28 " tempor incididunt ut labore et dolore magna aliqua.", "") frame]; |
| 29 EXPECT_LT(NSWidth(longMainNoSubFrame), 500); |
| 30 EXPECT_LT(NSHeight(shortMainNoSubFrame), NSHeight(longMainNoSubFrame)); |
| 31 |
| 32 NSRect shortMainMediumSubFrame = [constructView("abc", "foo bar baz") frame]; |
| 33 EXPECT_GT(NSWidth(shortMainMediumSubFrame), NSWidth(shortMainNoSubFrame)); |
| 34 EXPECT_GT(NSHeight(shortMainMediumSubFrame), NSHeight(shortMainNoSubFrame)); |
| 35 |
| 36 NSRect shortMainLongSubFrame = [constructView("abc", |
| 37 "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod" |
| 38 " tempor incididunt ut labore et dolore magna aliqua.") frame]; |
| 39 EXPECT_GT(NSWidth(shortMainLongSubFrame), NSWidth(shortMainMediumSubFrame)); |
| 40 EXPECT_LT(NSWidth(shortMainLongSubFrame), 500); |
| 41 EXPECT_GT(NSHeight(shortMainLongSubFrame), NSHeight(shortMainMediumSubFrame)); |
| 42 } |
| 43 |
| 44 } |
| 45 |
| OLD | NEW |