1 // Copyright (c) 2011 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 "chrome/browser/ui/cocoa/first_run_bubble_controller.h" 6 7 #import <Cocoa/Cocoa.h> 8 9 #include "base/debug/debugger.h" 10 #include "base/memory/scoped_nsobject.h" 11 #include "chrome/browser/ui/cocoa/browser_test_helper.h" 12 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" 13 #include "testing/gtest/include/gtest/gtest.h" 14 15 namespace { 16 17 class FirstRunBubbleControllerTest : public CocoaTest { 18 public: 19 BrowserTestHelper helper_; 20 }; 21 22 // Check that the bubble doesn't crash or leak. 23 TEST_F(FirstRunBubbleControllerTest, Init) { 24 scoped_nsobject<NSWindow> parent([[NSWindow alloc] 25 initWithContentRect:NSMakeRect(0, 0, 800, 600) 26 styleMask:NSBorderlessWindowMask 27 backing:NSBackingStoreBuffered 28 defer:NO]); 29 [parent setReleasedWhenClosed:NO]; 30 if (base::debug::BeingDebugged()) 31 [parent.get() orderFront:nil]; 32 else 33 [parent.get() orderBack:nil]; 34 35 FirstRunBubbleController* controller = [FirstRunBubbleController 36 showForView:[parent.get() contentView] 37 offset:NSMakePoint(300, 300) 38 profile:helper_.profile()]; 39 EXPECT_TRUE(controller != nil); 40 EXPECT_TRUE([[controller window] isVisible]); 41 [parent.get() close]; 42 } 43 44 } // namespace 45