[email protected] | 1ae9950 | 2009-05-19 20:46:37 | [diff] [blame] | 1 | // Copyright (c) 2009 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. |
| 4 | |
| 5 | #import <Cocoa/Cocoa.h> |
| 6 | |
| 7 | #include "base/scoped_nsobject.h" |
| 8 | #import "chrome/browser/cocoa/throbber_view.h" |
| 9 | #import "chrome/browser/cocoa/cocoa_test_helper.h" |
| 10 | #include "testing/gtest/include/gtest/gtest.h" |
| 11 | #include "testing/platform_test.h" |
| 12 | |
| 13 | namespace { |
| 14 | |
| 15 | class ThrobberViewTest : public PlatformTest { |
| 16 | public: |
| 17 | ThrobberViewTest() { |
| 18 | NSRect frame = NSMakeRect(10, 10, 16, 16); |
| 19 | NSBundle* bundle = mac_util::MainAppBundle(); |
| 20 | NSImage* image = [[[NSImage alloc] initByReferencingFile: |
| 21 | [bundle pathForResource:@"throbber" ofType:@"png"]] |
| 22 | autorelease]; |
[email protected] | 39e5624 | 2009-07-27 16:34:17 | [diff] [blame] | 23 | view_.reset([[ThrobberView filmstripThrobberViewWithFrame:frame |
| 24 | image:image] retain]); |
[email protected] | 1ae9950 | 2009-05-19 20:46:37 | [diff] [blame] | 25 | [cocoa_helper_.contentView() addSubview:view_.get()]; |
| 26 | } |
| 27 | |
| 28 | scoped_nsobject<ThrobberView> view_; |
| 29 | CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... |
| 30 | }; |
| 31 | |
| 32 | // Test adding/removing from the view hierarchy, mostly to ensure nothing |
| 33 | // leaks or crashes. |
| 34 | TEST_F(ThrobberViewTest, AddRemove) { |
| 35 | EXPECT_EQ(cocoa_helper_.contentView(), [view_ superview]); |
| 36 | [view_.get() removeFromSuperview]; |
| 37 | EXPECT_FALSE([view_ superview]); |
| 38 | } |
| 39 | |
| 40 | // Test drawing, mostly to ensure nothing leaks or crashes. |
| 41 | TEST_F(ThrobberViewTest, Display) { |
| 42 | [view_ display]; |
| 43 | } |
| 44 | |
| 45 | } // namespace |