| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/cocoa/tabpose_window.h" | 5 #import "chrome/browser/cocoa/tabpose_window.h" |
| 6 | 6 |
| 7 #include "base/scoped_nsobject.h" | 7 #import "chrome/browser/browser_window.h" |
| 8 #import "chrome/browser/cocoa/browser_test_helper.h" | 8 #import "chrome/browser/cocoa/browser_test_helper.h" |
| 9 #import "chrome/browser/cocoa/cocoa_test_helper.h" | 9 #import "chrome/browser/cocoa/cocoa_test_helper.h" |
| 10 #include "chrome/browser/renderer_host/site_instance.h" |
| 11 #include "chrome/browser/tab_contents/tab_contents.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 13 |
| 12 class TabposeWindowTest : public CocoaTest { | 14 class TabposeWindowTest : public CocoaTest { |
| 13 public: | 15 public: |
| 14 BrowserTestHelper browser_helper_; | 16 BrowserTestHelper browser_helper_; |
| 15 }; | 17 }; |
| 16 | 18 |
| 17 // Check that this doesn't leak. | 19 // Check that this doesn't leak. |
| 18 TEST_F(TabposeWindowTest, TestShow) { | 20 TEST_F(TabposeWindowTest, TestShow) { |
| 19 scoped_nsobject<NSWindow> parent([[NSWindow alloc] | 21 Browser* browser = browser_helper_.browser(); |
| 20 initWithContentRect:NSMakeRect(100, 200, 300, 200) | 22 BrowserWindow* browser_window = browser_helper_.CreateBrowserWindow(); |
| 21 styleMask:NSTitledWindowMask | 23 NSWindow* parent = browser_window->GetNativeHandle(); |
| 22 backing:NSBackingStoreBuffered | 24 |
| 23 defer:NO]); | |
| 24 [parent orderFront:nil]; | 25 [parent orderFront:nil]; |
| 25 EXPECT_TRUE([parent isVisible]); | 26 EXPECT_TRUE([parent isVisible]); |
| 26 | 27 |
| 28 // Add a few tabs to the tab strip model. |
| 29 TabStripModel* model = browser->tabstrip_model(); |
| 30 SiteInstance* instance = |
| 31 SiteInstance::CreateSiteInstance(browser_helper_.profile()); |
| 32 for (int i = 0; i < 3; ++i) { |
| 33 TabContents* tab_contents = |
| 34 new TabContents(browser_helper_.profile(), instance, MSG_ROUTING_NONE, |
| 35 NULL); |
| 36 model->AppendTabContents(tab_contents, /*foreground=*/true); |
| 37 } |
| 38 |
| 27 base::ScopedNSAutoreleasePool pool; | 39 base::ScopedNSAutoreleasePool pool; |
| 28 TabposeWindow* window = | 40 TabposeWindow* window = |
| 29 [TabposeWindow openTabposeFor:parent.get() | 41 [TabposeWindow openTabposeFor:parent |
| 30 rect:NSMakeRect(10, 20, 50, 60) | 42 rect:NSMakeRect(10, 20, 250, 160) |
| 31 slomo:NO]; | 43 slomo:NO |
| 44 tabStripModel:model]; |
| 32 | 45 |
| 33 // Should release the window. | 46 // Should release the window. |
| 34 [window mouseDown:nil]; | 47 [window mouseDown:nil]; |
| 48 |
| 49 browser_helper_.CloseBrowserWindow(); |
| 35 } | 50 } |
| OLD | NEW |