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