[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / validation_message_bubble_controller_unittest.mm
blob6d3ab984c8011566ccbd6f23a4f72b78f0ddff2e
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.
5 #import <Cocoa/Cocoa.h>
7 #include "base/strings/utf_string_conversions.h"
8 #import "chrome/browser/ui/cocoa/validation_message_bubble_controller.h"
9 #include "testing/gtest/include/gtest/gtest.h"
11 namespace {
13 static NSView* constructView(const char* main_text, const char* sub_text) {
14   return [ValidationMessageBubbleController
15       constructContentView:base::UTF8ToUTF16(main_text)
16                    subText:base::UTF8ToUTF16(sub_text)];
19 TEST(ValidationMessageBubbleControllerTest, FrameSize) {
20   NSRect shortMainNoSubFrame = [constructView("abc", "") frame];
21   EXPECT_GE(NSWidth(shortMainNoSubFrame), 40);
22   EXPECT_GT(NSHeight(shortMainNoSubFrame), 0);
24   NSRect longMainNoSubFrame = [constructView(
25       "very very very long text which overlfows the maximum window width. "
26       "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod"
27       " tempor incididunt ut labore et dolore magna aliqua.", "") frame];
28   EXPECT_LT(NSWidth(longMainNoSubFrame), 500);
29   EXPECT_LT(NSHeight(shortMainNoSubFrame), NSHeight(longMainNoSubFrame));
31   NSRect shortMainMediumSubFrame = [constructView("abc", "foo bar baz") frame];
32   EXPECT_GT(NSWidth(shortMainMediumSubFrame), NSWidth(shortMainNoSubFrame));
33   EXPECT_GT(NSHeight(shortMainMediumSubFrame), NSHeight(shortMainNoSubFrame));
35   NSRect shortMainLongSubFrame =  [constructView("abc",
36       "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod"
37       " tempor incididunt ut labore et dolore magna aliqua.") frame];
38   EXPECT_GT(NSWidth(shortMainLongSubFrame), NSWidth(shortMainMediumSubFrame));
39   EXPECT_LT(NSWidth(shortMainLongSubFrame), 500);
40   EXPECT_GT(NSHeight(shortMainLongSubFrame), NSHeight(shortMainMediumSubFrame));