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

Side by Side Diff: chrome/browser/ui/views/toolbar/browser_actions_container_browsertest.cc

Issue 1971463002: Get rid of some lingering MD-specific raster assets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: msw review Created 4 years, 7 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 "chrome/browser/ui/views/toolbar/browser_actions_container.h" 5 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" 10 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 EXPECT_EQ(container->GetViewForId(extension_a()->id()), 112 EXPECT_EQ(container->GetViewForId(extension_a()->id()),
113 container->child_at(0)); 113 container->child_at(0));
114 EXPECT_EQ(container->GetViewForId(extension_b()->id()), 114 EXPECT_EQ(container->GetViewForId(extension_b()->id()),
115 container->child_at(1)); 115 container->child_at(1));
116 EXPECT_EQ(container->GetViewForId(extension_c()->id()), 116 EXPECT_EQ(container->GetViewForId(extension_c()->id()),
117 container->child_at(2)); 117 container->child_at(2));
118 118
119 // Shrink the size of the container so we have an overflow menu. 119 // Shrink the size of the container so we have an overflow menu.
120 toolbar_model()->SetVisibleIconCount(2u); 120 toolbar_model()->SetVisibleIconCount(2u);
121 EXPECT_EQ(2u, container->VisibleBrowserActions()); 121 EXPECT_EQ(2u, container->VisibleBrowserActions());
122 ASSERT_TRUE(container->chevron());
123 EXPECT_TRUE(container->chevron()->visible());
124 122
125 // Simulate a drag and drop from the overflow menu. 123 // Simulate a drag and drop from the overflow menu.
126 ui::OSExchangeData drop_data3; 124 ui::OSExchangeData drop_data3;
127 // Drag extension C from index 2 (in the overflow menu)... 125 // Drag extension C from index 2 (in the overflow menu)...
128 BrowserActionDragData browser_action_drag_data3(extension_c()->id(), 2u); 126 BrowserActionDragData browser_action_drag_data3(extension_c()->id(), 2u);
129 browser_action_drag_data3.Write(profile(), &drop_data3); 127 browser_action_drag_data3.Write(profile(), &drop_data3);
130 // ...to the left of extension B (which is back in index 1 on the main bar). 128 // ...to the left of extension B (which is back in index 1 on the main bar).
131 location = gfx::Point(view->x(), view->y()); 129 location = gfx::Point(view->x(), view->y());
132 ui::DropTargetEvent target_event3( 130 ui::DropTargetEvent target_event3(
133 drop_data3, location, location, ui::DragDropTypes::DRAG_MOVE); 131 drop_data3, location, location, ui::DragDropTypes::DRAG_MOVE);
134 132
135 // Drag and drop. 133 // Drag and drop.
136 container->OnDragUpdated(target_event3); 134 container->OnDragUpdated(target_event3);
137 container->OnPerformDrop(target_event3); 135 container->OnPerformDrop(target_event3);
138 136
139 // The order should have changed *and* the container should have grown to 137 // The order should have changed *and* the container should have grown to
140 // accommodate extension C. The new order should be A C B, and all three 138 // accommodate extension C. The new order should be A C B, and all three
141 // extensions should be visible, with no overflow menu. 139 // extensions should be visible, with no overflow menu.
142 EXPECT_EQ(extension_a()->id(), browser_actions_bar()->GetExtensionId(0)); 140 EXPECT_EQ(extension_a()->id(), browser_actions_bar()->GetExtensionId(0));
143 EXPECT_EQ(extension_c()->id(), browser_actions_bar()->GetExtensionId(1)); 141 EXPECT_EQ(extension_c()->id(), browser_actions_bar()->GetExtensionId(1));
144 EXPECT_EQ(extension_b()->id(), browser_actions_bar()->GetExtensionId(2)); 142 EXPECT_EQ(extension_b()->id(), browser_actions_bar()->GetExtensionId(2));
145 EXPECT_EQ(3u, container->VisibleBrowserActions()); 143 EXPECT_EQ(3u, container->VisibleBrowserActions());
146 EXPECT_FALSE(container->chevron()->visible());
147 EXPECT_TRUE(toolbar_model()->all_icons_visible()); 144 EXPECT_TRUE(toolbar_model()->all_icons_visible());
148
149 // TODO(devlin): Ideally, we'd also have tests for dragging from the legacy
150 // overflow menu (i.e., chevron) to the main bar, but this requires either
151 // having a fairly complicated interactive UI test or finding a good way to
152 // mock up the BrowserActionOverflowMenuController.
153 } 145 }
154 146
155 // Test that changes performed in one container affect containers in other 147 // Test that changes performed in one container affect containers in other
156 // windows so that it is consistent. 148 // windows so that it is consistent.
157 IN_PROC_BROWSER_TEST_F(BrowserActionsBarBrowserTest, MultipleWindows) { 149 IN_PROC_BROWSER_TEST_F(BrowserActionsBarBrowserTest, MultipleWindows) {
158 LoadExtensions(); 150 LoadExtensions();
159 BrowserActionsContainer* first = 151 BrowserActionsContainer* first =
160 BrowserView::GetBrowserViewForBrowser(browser())->toolbar()-> 152 BrowserView::GetBrowserViewForBrowser(browser())->toolbar()->
161 browser_actions(); 153 browser_actions();
162 154
(...skipping 24 matching lines...) Expand all
187 gfx::Point location(view->x() + view->width(), view->y()); 179 gfx::Point location(view->x() + view->width(), view->y());
188 ui::DropTargetEvent target_event( 180 ui::DropTargetEvent target_event(
189 drop_data, location, location, ui::DragDropTypes::DRAG_MOVE); 181 drop_data, location, location, ui::DragDropTypes::DRAG_MOVE);
190 182
191 // Drag and drop. 183 // Drag and drop.
192 first->toolbar_actions_bar()->OnDragStarted(); 184 first->toolbar_actions_bar()->OnDragStarted();
193 first->OnDragUpdated(target_event); 185 first->OnDragUpdated(target_event);
194 186
195 // Semi-random placement for a regression test for crbug.com/539744. 187 // Semi-random placement for a regression test for crbug.com/539744.
196 first->Layout(); 188 first->Layout();
197 EXPECT_FALSE(first->chevron_for_testing()->visible());
198
199 first->OnPerformDrop(target_event); 189 first->OnPerformDrop(target_event);
200 190
201 // The new order, B A C, should be reflected in *both* containers, even 191 // The new order, B A C, should be reflected in *both* containers, even
202 // though the drag only happened in the first one. 192 // though the drag only happened in the first one.
203 EXPECT_EQ(extension_b()->id(), first->GetIdAt(0u)); 193 EXPECT_EQ(extension_b()->id(), first->GetIdAt(0u));
204 EXPECT_EQ(extension_b()->id(), second->GetIdAt(0u)); 194 EXPECT_EQ(extension_b()->id(), second->GetIdAt(0u));
205 EXPECT_EQ(extension_a()->id(), first->GetIdAt(1u)); 195 EXPECT_EQ(extension_a()->id(), first->GetIdAt(1u));
206 EXPECT_EQ(extension_a()->id(), second->GetIdAt(1u)); 196 EXPECT_EQ(extension_a()->id(), second->GetIdAt(1u));
207 EXPECT_EQ(extension_c()->id(), first->GetIdAt(2u)); 197 EXPECT_EQ(extension_c()->id(), first->GetIdAt(2u));
208 EXPECT_EQ(extension_c()->id(), second->GetIdAt(2u)); 198 EXPECT_EQ(extension_c()->id(), second->GetIdAt(2u));
209 199
210 // Next, simulate a resize by shrinking the container. 200 // Next, simulate a resize by shrinking the container.
211 first->OnResize(1, true); 201 first->OnResize(1, true);
212 // The first and second container should each have resized. 202 // The first and second container should each have resized.
213 EXPECT_EQ(2u, first->VisibleBrowserActions()); 203 EXPECT_EQ(2u, first->VisibleBrowserActions());
214 EXPECT_EQ(2u, second->VisibleBrowserActions()); 204 EXPECT_EQ(2u, second->VisibleBrowserActions());
215 EXPECT_TRUE(first->chevron_for_testing()->visible());
216 EXPECT_TRUE(second->chevron_for_testing()->visible());
217 } 205 }
218 206
219 // Test that the BrowserActionsContainer responds correctly when the underlying 207 // Test that the BrowserActionsContainer responds correctly when the underlying
220 // model enters highlight mode, and that browser actions are undraggable in 208 // model enters highlight mode, and that browser actions are undraggable in
221 // highlight mode. (Highlight mode itself it tested more thoroughly in the 209 // highlight mode. (Highlight mode itself it tested more thoroughly in the
222 // ToolbarActionsModel browsertests). 210 // ToolbarActionsModel browsertests).
223 IN_PROC_BROWSER_TEST_F(BrowserActionsBarBrowserTest, HighlightMode) { 211 IN_PROC_BROWSER_TEST_F(BrowserActionsBarBrowserTest, HighlightMode) {
224 LoadExtensions(); 212 LoadExtensions();
225 213
226 EXPECT_EQ(3, browser_actions_bar()->VisibleBrowserActions()); 214 EXPECT_EQ(3, browser_actions_bar()->VisibleBrowserActions());
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 457
470 main_bar()->OnDragUpdated(target_event3); 458 main_bar()->OnDragUpdated(target_event3);
471 main_bar()->OnPerformDrop(target_event3); 459 main_bar()->OnPerformDrop(target_event3);
472 460
473 // Order should be A C B, and there should be no extensions in overflow. 461 // Order should be A C B, and there should be no extensions in overflow.
474 EXPECT_EQ(extension_a()->id(), main_bar()->GetIdAt(0u)); 462 EXPECT_EQ(extension_a()->id(), main_bar()->GetIdAt(0u));
475 EXPECT_EQ(extension_c()->id(), main_bar()->GetIdAt(1u)); 463 EXPECT_EQ(extension_c()->id(), main_bar()->GetIdAt(1u));
476 EXPECT_EQ(extension_b()->id(), main_bar()->GetIdAt(2u)); 464 EXPECT_EQ(extension_b()->id(), main_bar()->GetIdAt(2u));
477 EXPECT_TRUE(VerifyVisibleCount(3u)); 465 EXPECT_TRUE(VerifyVisibleCount(3u));
478 } 466 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/toolbar/browser_actions_container.cc ('k') | chrome/browser/ui/views/toolbar/chevron_menu_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698