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

Side by Side Diff: ash/frame/caption_buttons/frame_caption_button_container_view_unittest.cc

Issue 553333007: [Ash] Always show minimize button. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove enum MinimizeAllowed. Created 6 years, 3 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h" 5 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h"
6 6
7 #include "ash/frame/caption_buttons/frame_caption_button.h" 7 #include "ash/frame/caption_buttons/frame_caption_button.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/test/ash_test_base.h" 9 #include "ash/test/ash_test_base.h"
10 #include "ash/wm/maximize_mode/maximize_mode_controller.h" 10 #include "ash/wm/maximize_mode/maximize_mode_controller.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 return false; 98 return false;
99 } 99 }
100 100
101 private: 101 private:
102 DISALLOW_COPY_AND_ASSIGN(FrameCaptionButtonContainerViewTest); 102 DISALLOW_COPY_AND_ASSIGN(FrameCaptionButtonContainerViewTest);
103 }; 103 };
104 104
105 // Test how the allowed actions affect which caption buttons are visible. 105 // Test how the allowed actions affect which caption buttons are visible.
106 TEST_F(FrameCaptionButtonContainerViewTest, ButtonVisibility) { 106 TEST_F(FrameCaptionButtonContainerViewTest, ButtonVisibility) {
107 // All the buttons should be visible when minimizing and maximizing are 107 // All the buttons should be visible when minimizing and maximizing are
108 // allowed. 108 // allowed.
pkotwicz 2014/09/19 03:34:31 Nit: Remove mention of minimizng being allowed
109 scoped_ptr<views::Widget> widget_can_maximize( 109 scoped_ptr<views::Widget> widget_can_maximize(
110 CreateTestWidget(MAXIMIZE_ALLOWED)); 110 CreateTestWidget(MAXIMIZE_ALLOWED));
111 FrameCaptionButtonContainerView container1(widget_can_maximize.get(), 111 FrameCaptionButtonContainerView container1(widget_can_maximize.get());
112 FrameCaptionButtonContainerView::MINIMIZE_ALLOWED);
113 SetMockImages(&container1); 112 SetMockImages(&container1);
114 container1.Layout(); 113 container1.Layout();
115 FrameCaptionButtonContainerView::TestApi t1(&container1); 114 FrameCaptionButtonContainerView::TestApi t1(&container1);
116 EXPECT_TRUE(t1.minimize_button()->visible()); 115 EXPECT_TRUE(t1.minimize_button()->visible());
117 EXPECT_TRUE(t1.size_button()->visible()); 116 EXPECT_TRUE(t1.size_button()->visible());
118 EXPECT_TRUE(t1.close_button()->visible()); 117 EXPECT_TRUE(t1.close_button()->visible());
119 EXPECT_TRUE(CheckButtonsAtEdges( 118 EXPECT_TRUE(CheckButtonsAtEdges(
120 &container1, *t1.minimize_button(), *t1.close_button())); 119 &container1, *t1.minimize_button(), *t1.close_button()));
121 120
122 // The minimize button should be visible when minimizing is allowed but 121 // The minimize button should still be visible when maximizing is disallowed.
pkotwicz 2014/09/19 03:34:31 How about: "The maximize button should not be visi
123 // maximizing is disallowed.
124 scoped_ptr<views::Widget> widget_cannot_maximize( 122 scoped_ptr<views::Widget> widget_cannot_maximize(
125 CreateTestWidget(MAXIMIZE_DISALLOWED)); 123 CreateTestWidget(MAXIMIZE_DISALLOWED));
126 FrameCaptionButtonContainerView container2(widget_cannot_maximize.get(), 124 FrameCaptionButtonContainerView container2(widget_cannot_maximize.get());
127 FrameCaptionButtonContainerView::MINIMIZE_ALLOWED);
128 SetMockImages(&container2); 125 SetMockImages(&container2);
129 container2.Layout(); 126 container2.Layout();
130 FrameCaptionButtonContainerView::TestApi t2(&container2); 127 FrameCaptionButtonContainerView::TestApi t2(&container2);
131 EXPECT_TRUE(t2.minimize_button()->visible()); 128 EXPECT_TRUE(t2.minimize_button()->visible());
132 EXPECT_FALSE(t2.size_button()->visible()); 129 EXPECT_FALSE(t2.size_button()->visible());
133 EXPECT_TRUE(t2.close_button()->visible()); 130 EXPECT_TRUE(t2.close_button()->visible());
134 EXPECT_TRUE(CheckButtonsAtEdges( 131 EXPECT_TRUE(CheckButtonsAtEdges(
135 &container2, *t2.minimize_button(), *t2.close_button())); 132 &container2, *t2.minimize_button(), *t2.close_button()));
136
137 // Neither the minimize button nor the size button should be visible when
138 // neither minimizing nor maximizing are allowed.
139 FrameCaptionButtonContainerView container3(widget_cannot_maximize.get(),
140 FrameCaptionButtonContainerView::MINIMIZE_DISALLOWED);
141 SetMockImages(&container3);
142 container3.Layout();
143 FrameCaptionButtonContainerView::TestApi t3(&container3);
144 EXPECT_FALSE(t3.minimize_button()->visible());
145 EXPECT_FALSE(t3.size_button()->visible());
146 EXPECT_TRUE(t3.close_button()->visible());
147 EXPECT_TRUE(CheckButtonsAtEdges(
148 &container3, *t3.close_button(), *t3.close_button()));
149 } 133 }
150 134
151 // Tests that the layout animations trigered by button visibility result in the 135 // Tests that the layout animations trigered by button visibility result in the
152 // correct placement of the buttons. 136 // correct placement of the buttons.
153 TEST_F(FrameCaptionButtonContainerViewTest, 137 TEST_F(FrameCaptionButtonContainerViewTest,
154 TestUpdateSizeButtonVisibilityAnimation) { 138 TestUpdateSizeButtonVisibilityAnimation) {
155 scoped_ptr<views::Widget> widget_can_maximize( 139 scoped_ptr<views::Widget> widget_can_maximize(
156 CreateTestWidget(MAXIMIZE_ALLOWED)); 140 CreateTestWidget(MAXIMIZE_ALLOWED));
157 FrameCaptionButtonContainerView container(widget_can_maximize.get(), 141 FrameCaptionButtonContainerView container(widget_can_maximize.get());
158 FrameCaptionButtonContainerView::MINIMIZE_ALLOWED);
159 SetMockImages(&container); 142 SetMockImages(&container);
160 container.SetBoundsRect(gfx::Rect(container.GetPreferredSize())); 143 container.SetBoundsRect(gfx::Rect(container.GetPreferredSize()));
161 container.Layout(); 144 container.Layout();
162 145
163 FrameCaptionButtonContainerView::TestApi test(&container); 146 FrameCaptionButtonContainerView::TestApi test(&container);
164 gfx::Rect initial_minimize_button_bounds = test.minimize_button()->bounds(); 147 gfx::Rect initial_minimize_button_bounds = test.minimize_button()->bounds();
165 gfx::Rect initial_size_button_bounds = test.size_button()->bounds(); 148 gfx::Rect initial_size_button_bounds = test.size_button()->bounds();
166 gfx::Rect initial_close_button_bounds = test.close_button()->bounds(); 149 gfx::Rect initial_close_button_bounds = test.close_button()->bounds();
167 gfx::Rect initial_container_bounds = container.bounds(); 150 gfx::Rect initial_container_bounds = container.bounds();
168 151
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 EXPECT_TRUE(test.size_button()->visible()); 186 EXPECT_TRUE(test.size_button()->visible());
204 EXPECT_TRUE(test.close_button()->visible()); 187 EXPECT_TRUE(test.close_button()->visible());
205 EXPECT_EQ(initial_minimize_button_bounds, test.minimize_button()->bounds()); 188 EXPECT_EQ(initial_minimize_button_bounds, test.minimize_button()->bounds());
206 EXPECT_EQ(initial_size_button_bounds, test.size_button()->bounds()); 189 EXPECT_EQ(initial_size_button_bounds, test.size_button()->bounds());
207 EXPECT_EQ(initial_close_button_bounds, test.close_button()->bounds()); 190 EXPECT_EQ(initial_close_button_bounds, test.close_button()->bounds());
208 EXPECT_EQ(container.GetPreferredSize().width(), 191 EXPECT_EQ(container.GetPreferredSize().width(),
209 initial_container_bounds.width()); 192 initial_container_bounds.width());
210 } 193 }
211 194
212 } // namespace ash 195 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698