Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(258)

Side by Side Diff: chrome/browser/ui/cocoa/tabpose_window_unittest.mm

Issue 154083008: Remove Tabpose feature on mac, and supporting infrastructure (PaintAtSize) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, merge Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/cocoa/tabpose_window.mm ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #import "chrome/browser/ui/cocoa/tabpose_window.h"
6
7 #include "base/mac/mac_util.h"
8 #include "chrome/browser/ui/browser_window.h"
9 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
10 #include "chrome/browser/ui/tabs/tab_strip_model.h"
11 #include "chrome/test/base/testing_profile.h"
12 #include "content/public/browser/site_instance.h"
13 #include "content/public/browser/web_contents.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15
16 using content::SiteInstance;
17
18 class TabposeWindowTest : public CocoaProfileTest {
19 public:
20 virtual void SetUp() {
21 CocoaProfileTest::SetUp();
22 ASSERT_TRUE(profile());
23
24 site_instance_ = SiteInstance::Create(profile());
25 }
26
27 void AppendTabToStrip() {
28 content::WebContents* web_contents = content::WebContents::Create(
29 content::WebContents::CreateParams(profile(), site_instance_.get()));
30 browser()->tab_strip_model()->AppendWebContents(
31 web_contents, /*foreground=*/true);
32 }
33
34 scoped_refptr<SiteInstance> site_instance_;
35 };
36
37 TEST_F(TabposeWindowTest, TestShow) {
38 // Skip this test on 10.7
39 // http://code.google.com/p/chromium/issues/detail?id=127845
40 if (base::mac::IsOSLionOrLater()) {
41 return;
42 }
43
44 NSWindow* parent = browser()->window()->GetNativeWindow();
45
46 [parent orderFront:nil];
47 EXPECT_TRUE([parent isVisible]);
48
49 // Add a few tabs to the tab strip model.
50 for (int i = 0; i < 3; ++i)
51 AppendTabToStrip();
52
53 base::mac::ScopedNSAutoreleasePool pool;
54 TabposeWindow* window =
55 [TabposeWindow openTabposeFor:parent
56 rect:NSMakeRect(10, 20, 250, 160)
57 slomo:NO
58 tabStripModel:browser()->tab_strip_model()];
59
60 // Should release the window.
61 [window mouseDown:nil];
62 }
63
64 TEST_F(TabposeWindowTest, TestModelObserver) {
65 // Skip this test on 10.7
66 // http://code.google.com/p/chromium/issues/detail?id=127845
67 if (base::mac::IsOSLionOrLater()) {
68 return;
69 }
70
71 NSWindow* parent = browser()->window()->GetNativeWindow();
72 [parent orderFront:nil];
73
74 // Add a few tabs to the tab strip model.
75 for (int i = 0; i < 3; ++i)
76 AppendTabToStrip();
77
78 base::mac::ScopedNSAutoreleasePool pool;
79 TabposeWindow* window =
80 [TabposeWindow openTabposeFor:parent
81 rect:NSMakeRect(10, 20, 250, 160)
82 slomo:NO
83 tabStripModel:browser()->tab_strip_model()];
84
85 // Exercise all the model change events.
86 TabStripModel* model = browser()->tab_strip_model();
87 DCHECK_EQ([window thumbnailLayerCount], 3u);
88 DCHECK_EQ([window selectedIndex], 2);
89
90 model->MoveWebContentsAt(0, 2, /*select_after_move=*/false);
91 DCHECK_EQ([window thumbnailLayerCount], 3u);
92 DCHECK_EQ([window selectedIndex], 1);
93
94 model->MoveWebContentsAt(2, 0, /*select_after_move=*/false);
95 DCHECK_EQ([window thumbnailLayerCount], 3u);
96 DCHECK_EQ([window selectedIndex], 2);
97
98 [window selectTileAtIndexWithoutAnimation:0];
99 DCHECK_EQ([window selectedIndex], 0);
100
101 model->MoveWebContentsAt(0, 2, /*select_after_move=*/false);
102 DCHECK_EQ([window selectedIndex], 2);
103
104 model->MoveWebContentsAt(2, 0, /*select_after_move=*/false);
105 DCHECK_EQ([window selectedIndex], 0);
106
107 delete model->DetachWebContentsAt(0);
108 DCHECK_EQ([window thumbnailLayerCount], 2u);
109 DCHECK_EQ([window selectedIndex], 0);
110
111 AppendTabToStrip();
112 DCHECK_EQ([window thumbnailLayerCount], 3u);
113 DCHECK_EQ([window selectedIndex], 0);
114
115 model->CloseWebContentsAt(0, TabStripModel::CLOSE_NONE);
116 DCHECK_EQ([window thumbnailLayerCount], 2u);
117 DCHECK_EQ([window selectedIndex], 0);
118
119 [window selectTileAtIndexWithoutAnimation:1];
120 model->CloseWebContentsAt(0, TabStripModel::CLOSE_NONE);
121 DCHECK_EQ([window thumbnailLayerCount], 1u);
122 DCHECK_EQ([window selectedIndex], 0);
123
124 // Should release the window.
125 [window mouseDown:nil];
126 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/tabpose_window.mm ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698