| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #include "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
| 8 #include "base/scoped_nsobject.h" | 8 #include "base/scoped_nsobject.h" |
| 9 #import "chrome/browser/cocoa/throbber_view.h" | 9 #import "chrome/browser/cocoa/throbber_view.h" |
| 10 #import "chrome/browser/cocoa/cocoa_test_helper.h" | 10 #import "chrome/browser/cocoa/cocoa_test_helper.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "testing/platform_test.h" | 12 #include "testing/platform_test.h" |
| 13 #include "grit/app_resources.h" | 13 #include "grit/app_resources.h" |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 class ThrobberViewTest : public PlatformTest { | 17 class ThrobberViewTest : public CocoaTest { |
| 18 public: | 18 public: |
| 19 ThrobberViewTest() { | 19 ThrobberViewTest() { |
| 20 NSRect frame = NSMakeRect(10, 10, 16, 16); | 20 NSRect frame = NSMakeRect(10, 10, 16, 16); |
| 21 NSImage* image = | 21 NSImage* image = |
| 22 ResourceBundle::GetSharedInstance().GetNSImageNamed(IDR_THROBBER); | 22 ResourceBundle::GetSharedInstance().GetNSImageNamed(IDR_THROBBER); |
| 23 view_.reset([[ThrobberView filmstripThrobberViewWithFrame:frame | 23 view_ = [ThrobberView filmstripThrobberViewWithFrame:frame image:image]; |
| 24 image:image] retain]); | 24 [[test_window() contentView] addSubview:view_]; |
| 25 [cocoa_helper_.contentView() addSubview:view_.get()]; | |
| 26 } | 25 } |
| 27 | 26 |
| 28 scoped_nsobject<ThrobberView> view_; | 27 ThrobberView* view_; |
| 29 CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... | |
| 30 }; | 28 }; |
| 31 | 29 |
| 32 // Test adding/removing from the view hierarchy, mostly to ensure nothing | 30 TEST_VIEW(ThrobberViewTest, view_) |
| 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 | 31 |
| 45 } // namespace | 32 } // namespace |
| OLD | NEW |