blob: 2cf2db4aeb2904c49071442cf1874667a1fd4d8a [file] [log] [blame]
[email protected]1ae99502009-05-19 20:46:371// 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
13namespace {
14
15class 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]39e56242009-07-27 16:34:1723 view_.reset([[ThrobberView filmstripThrobberViewWithFrame:frame
24 image:image] retain]);
[email protected]1ae99502009-05-19 20:46:3725 [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.
34TEST_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.
41TEST_F(ThrobberViewTest, Display) {
42 [view_ display];
43}
44
45} // namespace