- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / views / validation_message_bubble_delegate_unittest.cc
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 #include "chrome/browser/ui/views/validation_message_bubble_delegate.h"
6
7 #include "base/strings/utf_string_conversions.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 namespace {
11
12 gfx::Size GetSizeForMessages(const std::string& main_text,
13                              const std::string& sub_text) {
14   ValidationMessageBubbleDelegate delegate(
15       gfx::Rect(), UTF8ToUTF16(main_text), UTF8ToUTF16(sub_text), NULL);
16   return delegate.GetPreferredSize();
17 }
18
19 TEST(ValidationMessageBubbleDelegate, Size) {
20   gfx::Size short_main_empty_sub_size = GetSizeForMessages("foo", "");
21   EXPECT_LE(ValidationMessageBubbleDelegate::kWindowMinWidth,
22             short_main_empty_sub_size.width());
23   EXPECT_LE(0, short_main_empty_sub_size.height());
24
25   gfx::Size long_main_empty_sub_size = GetSizeForMessages(
26       "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod"
27       " tempor incididunt ut labore et dolore magna aliqua.", "");
28   EXPECT_GE(ValidationMessageBubbleDelegate::kWindowMaxWidth,
29             long_main_empty_sub_size.width());
30   EXPECT_GT(long_main_empty_sub_size.height(),
31             short_main_empty_sub_size.height());
32
33   gfx::Size short_main_medium_sub_size =
34       GetSizeForMessages("foo", "foo bar baz");
35   EXPECT_GT(short_main_medium_sub_size.width(),
36             short_main_empty_sub_size.width());
37   EXPECT_GT(short_main_medium_sub_size.height(),
38             short_main_empty_sub_size.height());
39
40   gfx::Size short_main_long_sub_size = GetSizeForMessages("foo",
41       "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod"
42       " tempor incididunt ut labore et dolore magna aliqua.");
43   EXPECT_GT(short_main_long_sub_size.width(),
44             short_main_medium_sub_size.width());
45   EXPECT_GE(ValidationMessageBubbleDelegate::kWindowMaxWidth,
46             short_main_long_sub_size.width());
47   EXPECT_GT(short_main_long_sub_size.height(),
48             short_main_medium_sub_size.height());
49 }
50
51 }