Chromium Code Reviews| Index: chrome/browser/ui/views/validation_message_bubble_delegate_unittest.cc |
| diff --git a/chrome/browser/ui/views/validation_message_bubble_delegate_unittest.cc b/chrome/browser/ui/views/validation_message_bubble_delegate_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a9661eaea379960be36011d22604c807e93f3cf2 |
| --- /dev/null |
| +++ b/chrome/browser/ui/views/validation_message_bubble_delegate_unittest.cc |
| @@ -0,0 +1,43 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/ui/views/validation_message_bubble_delegate.h" |
|
sky
2013/04/30 13:53:21
nit: newline between 5/6.
tkent
2013/05/01 03:15:02
Done.
|
| +#include "base/utf_string_conversions.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +namespace { |
| + |
| +gfx::Size GetSizeForMessages(const char* main_text, const char* sub_text) { |
|
sky
2013/04/30 13:53:21
Make these take const std::string&.
tkent
2013/05/01 03:15:02
Done.
|
| + scoped_ptr<ValidationMessageBubbleDelegate> delegate( |
|
sky
2013/04/30 13:53:21
Why the scoped_ptr here? Why not create on the sta
tkent
2013/05/01 03:15:02
No reason to use scoped_ptr. Changed to an object
|
| + new ValidationMessageBubbleDelegate( |
| + gfx::Rect(), UTF8ToUTF16(main_text), UTF8ToUTF16(sub_text))); |
| + return delegate->GetPreferredSize(); |
| +} |
| + |
| +TEST(ValidationMessageBubbleDelegate, Size) { |
| + gfx::Size shortMainEmptySubSize = GetSizeForMessages("foo", ""); |
|
sky
2013/04/30 13:53:21
short_main_empty_sub_size, in fact you have the wr
tkent
2013/05/01 03:15:02
Updated all local variables.
|
| + EXPECT_GT(shortMainEmptySubSize.width(), 40); |
|
sky
2013/04/30 13:53:21
Where do these numbers come from?
tkent
2013/05/01 03:15:02
It is a value smaller than kWindowMinWidth.
Using
sky
2013/05/01 14:05:05
Duplicating the values of constants defeats the va
tkent
2013/05/01 21:42:30
Done.
|
| + EXPECT_GT(shortMainEmptySubSize.height(), 0); |
| + |
| + gfx::Size longMainEmptySubSize = GetSizeForMessages( |
| + "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod" |
| + " tempor incididunt ut labore et dolore magna aliqua.", ""); |
| + EXPECT_LT(longMainEmptySubSize.width(), 500); |
| + EXPECT_GT(longMainEmptySubSize.height(), shortMainEmptySubSize.height()); |
| + |
| + gfx::Size shortMainMediumSubSize = |
| + GetSizeForMessages("foo", "foo bar baz"); |
| + EXPECT_GT(shortMainMediumSubSize.width(), shortMainEmptySubSize.width()); |
| + EXPECT_GT(shortMainMediumSubSize.height(), shortMainEmptySubSize.height()); |
| + |
| + gfx::Size shortMainLongSubSize = GetSizeForMessages("foo", |
| + "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod" |
| + " tempor incididunt ut labore et dolore magna aliqua."); |
| + EXPECT_GT(shortMainLongSubSize.width(), shortMainMediumSubSize.width()); |
| + EXPECT_LT(shortMainLongSubSize.width(), 500); |
| + EXPECT_GT(shortMainLongSubSize.height(), shortMainMediumSubSize.height()); |
| + |
|
sky
2013/04/30 13:53:21
No new empty line here.
tkent
2013/05/01 03:15:02
Done.
|
| +} |
| + |
| +} |