OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/cocoa/tabpose_window.h" | 5 #import "chrome/browser/ui/cocoa/tabpose_window.h" |
6 | 6 |
7 #include "chrome/browser/ui/browser_tabstrip.h" | 7 #include "chrome/browser/ui/browser_tabstrip.h" |
8 #include "chrome/browser/ui/browser_window.h" | 8 #include "chrome/browser/ui/browser_window.h" |
9 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" | 9 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" |
10 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 10 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 profile(), site_instance_, MSG_ROUTING_NONE, NULL, NULL); | 29 profile(), site_instance_, MSG_ROUTING_NONE, NULL, NULL); |
30 browser()->tab_strip_model()->AppendTabContents( | 30 browser()->tab_strip_model()->AppendTabContents( |
31 tab_contents, /*foreground=*/true); | 31 tab_contents, /*foreground=*/true); |
32 } | 32 } |
33 | 33 |
34 scoped_refptr<SiteInstance> site_instance_; | 34 scoped_refptr<SiteInstance> site_instance_; |
35 }; | 35 }; |
36 | 36 |
37 // Check that this doesn't leak. | 37 // Check that this doesn't leak. |
38 TEST_F(TabposeWindowTest, TestShow) { | 38 TEST_F(TabposeWindowTest, TestShow) { |
39 BrowserWindow* browser_window = CreateBrowserWindow(); | 39 NSWindow* parent = browser()->window()->GetNativeWindow(); |
40 NSWindow* parent = browser_window->GetNativeWindow(); | |
41 | 40 |
42 [parent orderFront:nil]; | 41 [parent orderFront:nil]; |
43 EXPECT_TRUE([parent isVisible]); | 42 EXPECT_TRUE([parent isVisible]); |
44 | 43 |
45 // Add a few tabs to the tab strip model. | 44 // Add a few tabs to the tab strip model. |
46 for (int i = 0; i < 3; ++i) | 45 for (int i = 0; i < 3; ++i) |
47 AppendTabToStrip(); | 46 AppendTabToStrip(); |
48 | 47 |
49 base::mac::ScopedNSAutoreleasePool pool; | 48 base::mac::ScopedNSAutoreleasePool pool; |
50 TabposeWindow* window = | 49 TabposeWindow* window = |
51 [TabposeWindow openTabposeFor:parent | 50 [TabposeWindow openTabposeFor:parent |
52 rect:NSMakeRect(10, 20, 250, 160) | 51 rect:NSMakeRect(10, 20, 250, 160) |
53 slomo:NO | 52 slomo:NO |
54 tabStripModel:browser()->tab_strip_model()]; | 53 tabStripModel:browser()->tab_strip_model()]; |
55 | 54 |
56 // Should release the window. | 55 // Should release the window. |
57 [window mouseDown:nil]; | 56 [window mouseDown:nil]; |
58 } | 57 } |
59 | 58 |
60 TEST_F(TabposeWindowTest, TestModelObserver) { | 59 TEST_F(TabposeWindowTest, TestModelObserver) { |
61 BrowserWindow* browser_window = CreateBrowserWindow(); | 60 NSWindow* parent = browser()->window()->GetNativeWindow(); |
62 NSWindow* parent = browser_window->GetNativeWindow(); | |
63 [parent orderFront:nil]; | 61 [parent orderFront:nil]; |
64 | 62 |
65 // Add a few tabs to the tab strip model. | 63 // Add a few tabs to the tab strip model. |
66 for (int i = 0; i < 3; ++i) | 64 for (int i = 0; i < 3; ++i) |
67 AppendTabToStrip(); | 65 AppendTabToStrip(); |
68 | 66 |
69 base::mac::ScopedNSAutoreleasePool pool; | 67 base::mac::ScopedNSAutoreleasePool pool; |
70 TabposeWindow* window = | 68 TabposeWindow* window = |
71 [TabposeWindow openTabposeFor:parent | 69 [TabposeWindow openTabposeFor:parent |
72 rect:NSMakeRect(10, 20, 250, 160) | 70 rect:NSMakeRect(10, 20, 250, 160) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 DCHECK_EQ([window selectedIndex], 0); | 106 DCHECK_EQ([window selectedIndex], 0); |
109 | 107 |
110 [window selectTileAtIndexWithoutAnimation:1]; | 108 [window selectTileAtIndexWithoutAnimation:1]; |
111 model->CloseTabContentsAt(0, TabStripModel::CLOSE_NONE); | 109 model->CloseTabContentsAt(0, TabStripModel::CLOSE_NONE); |
112 DCHECK_EQ([window thumbnailLayerCount], 1u); | 110 DCHECK_EQ([window thumbnailLayerCount], 1u); |
113 DCHECK_EQ([window selectedIndex], 0); | 111 DCHECK_EQ([window selectedIndex], 0); |
114 | 112 |
115 // Should release the window. | 113 // Should release the window. |
116 [window mouseDown:nil]; | 114 [window mouseDown:nil]; |
117 } | 115 } |
OLD | NEW |