Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / extensions / browser_actions_container_view_unittest.mm
blob8e8d07703d6a8602fc88fc5579dd82238aeb93f5
1 // Copyright (c) 2011 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 #include "base/mac/scoped_nsobject.h"
6 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
7 #import "chrome/browser/ui/cocoa/extensions/browser_actions_container_view.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "testing/platform_test.h"
11 namespace {
13 const CGFloat kContainerHeight = 15.0;
14 const CGFloat kMinimumContainerWidth = 10.0;
16 class BrowserActionsContainerViewTest : public CocoaTest {
17  public:
18   virtual void SetUp() {
19     CocoaTest::SetUp();
20     view_.reset([[BrowserActionsContainerView alloc]
21         initWithFrame:NSMakeRect(0, 0, 0, kContainerHeight)]);
22   }
24   base::scoped_nsobject<BrowserActionsContainerView> view_;
27 TEST_F(BrowserActionsContainerViewTest, BasicTests) {
28   EXPECT_TRUE([view_ isResizable]);
29   EXPECT_TRUE([view_ canDragLeft]);
30   EXPECT_TRUE([view_ canDragRight]);
31   EXPECT_TRUE([view_ isHidden]);
34 TEST_F(BrowserActionsContainerViewTest, SetWidthTests) {
35   // Try setting below the minimum width (10 pixels).
36   [view_ resizeToWidth:5.0 animate:NO];
37   EXPECT_EQ(kMinimumContainerWidth, NSWidth([view_ frame])) << "Frame width is "
38       << "less than the minimum allowed.";
39   // Since the frame expands to the left, the x-position delta value will be
40   // negative.
41   EXPECT_EQ(-kMinimumContainerWidth, [view_ resizeDeltaX]);
43   [view_ resizeToWidth:35.0 animate:NO];
44   EXPECT_EQ(35.0, NSWidth([view_ frame]));
45   EXPECT_EQ(-25.0, [view_ resizeDeltaX]);
47   [view_ resizeToWidth:20.0 animate:NO];
48   EXPECT_EQ(20.0, NSWidth([view_ frame]));
49   EXPECT_EQ(15.0, [view_ resizeDeltaX]);
52 }  // namespace