diff options
author | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-21 14:24:54 +0000 |
---|---|---|
committer | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-21 14:24:54 +0000 |
commit | 7a54688883ec2f15fbf5da68a5c011d322ff6292 (patch) | |
tree | 89d63185a2f44b27bfbecf681febf4707f1e3f79 /chrome/browser/cocoa | |
parent | 79e966831a3f3600705f72b632929bfa570e672d (diff) | |
download | chromium_src-7a54688883ec2f15fbf5da68a5c011d322ff6292.zip chromium_src-7a54688883ec2f15fbf5da68a5c011d322ff6292.tar.gz chromium_src-7a54688883ec2f15fbf5da68a5c011d322ff6292.tar.bz2 |
Unit tests for button cells we use in the UI.
Review URL: http://codereview.chromium.org/87023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14098 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r-- | chrome/browser/cocoa/tab_cell_unittest.mm | 41 | ||||
-rw-r--r-- | chrome/browser/cocoa/toolbar_button_cell_unittest.mm | 42 |
2 files changed, 83 insertions, 0 deletions
diff --git a/chrome/browser/cocoa/tab_cell_unittest.mm b/chrome/browser/cocoa/tab_cell_unittest.mm new file mode 100644 index 0000000..c27c197 --- /dev/null +++ b/chrome/browser/cocoa/tab_cell_unittest.mm @@ -0,0 +1,41 @@ +// Copyright (c) 2009 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. + +#import <Cocoa/Cocoa.h> + +#include "base/scoped_nsobject.h" +#import "chrome/browser/cocoa/tab_cell.h" +#import "chrome/browser/cocoa/cocoa_test_helper.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace { + +class TabCellTest : public testing::Test { + public: + TabCellTest() { + NSRect frame = NSMakeRect(0, 0, 50, 30); + view_.reset([[NSButton alloc] initWithFrame:frame]); + scoped_nsobject<TabCell> cell([[TabCell alloc] initTextCell:@"Testing"]); + [view_ setCell:cell.get()]; + [cocoa_helper_.contentView() addSubview:view_.get()]; + } + + CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... + scoped_nsobject<NSButton> view_; +}; + +// Test adding/removing from the view hierarchy, mostly to ensure nothing +// leaks or crashes. +TEST_F(TabCellTest, AddRemove) { + EXPECT_EQ(cocoa_helper_.contentView(), [view_ superview]); + [view_.get() removeFromSuperview]; + EXPECT_FALSE([view_ superview]); +} + +// Test drawing, mostly to ensure nothing leaks or crashes. +TEST_F(TabCellTest, Display) { + [view_ display]; +} + +} // namespace diff --git a/chrome/browser/cocoa/toolbar_button_cell_unittest.mm b/chrome/browser/cocoa/toolbar_button_cell_unittest.mm new file mode 100644 index 0000000..e1cb467 --- /dev/null +++ b/chrome/browser/cocoa/toolbar_button_cell_unittest.mm @@ -0,0 +1,42 @@ +// Copyright (c) 2009 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. + +#import <Cocoa/Cocoa.h> + +#include "base/scoped_nsobject.h" +#import "chrome/browser/cocoa/toolbar_button_cell.h" +#import "chrome/browser/cocoa/cocoa_test_helper.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace { + +class ToolbarButtonCellTest : public testing::Test { + public: + ToolbarButtonCellTest() { + NSRect frame = NSMakeRect(0, 0, 50, 30); + view_.reset([[NSButton alloc] initWithFrame:frame]); + scoped_nsobject<ToolbarButtonCell> cell([[ToolbarButtonCell alloc] + initTextCell:@"Testing"]); + [view_ setCell:cell.get()]; + [cocoa_helper_.contentView() addSubview:view_.get()]; + } + + CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... + scoped_nsobject<NSButton> view_; +}; + +// Test adding/removing from the view hierarchy, mostly to ensure nothing +// leaks or crashes. +TEST_F(ToolbarButtonCellTest, AddRemove) { + EXPECT_EQ(cocoa_helper_.contentView(), [view_ superview]); + [view_.get() removeFromSuperview]; + EXPECT_FALSE([view_ superview]); +} + +// Test drawing, mostly to ensure nothing leaks or crashes. +TEST_F(ToolbarButtonCellTest, Display) { + [view_ display]; +} + +} // namespace |