summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-21 14:24:54 +0000
committerpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-21 14:24:54 +0000
commit7a54688883ec2f15fbf5da68a5c011d322ff6292 (patch)
tree89d63185a2f44b27bfbecf681febf4707f1e3f79
parent79e966831a3f3600705f72b632929bfa570e672d (diff)
downloadchromium_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
-rw-r--r--chrome/browser/cocoa/tab_cell_unittest.mm41
-rw-r--r--chrome/browser/cocoa/toolbar_button_cell_unittest.mm42
-rw-r--r--chrome/chrome.gyp2
3 files changed, 85 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
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index eb3a63a..da398e1 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -2148,9 +2148,11 @@
'browser/cocoa/location_bar_view_mac_unittest.mm',
'browser/cocoa/grow_box_view_unittest.mm',
'browser/cocoa/status_bubble_mac_unittest.mm',
+ 'browser/cocoa/tab_cell_unittest.mm',
'browser/cocoa/tab_controller_unittest.mm',
'browser/cocoa/tab_strip_view_unittest.mm',
'browser/cocoa/tab_view_unittest.mm',
+ 'browser/cocoa/toolbar_button_cell_unittest.mm',
'browser/cocoa/toolbar_controller_unittest.mm',
'browser/cocoa/toolbar_view_unittest.mm',
'browser/command_updater_unittest.cc',