| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/command_line.h" | 5 #include "chrome/browser/ui/panels/base_panel_browser_test.h" |
| 6 #include "base/mac/scoped_nsautorelease_pool.h" | 6 |
| 7 #include "chrome/browser/extensions/extension_service.h" | |
| 8 #include "chrome/browser/prefs/pref_service.h" | 7 #include "chrome/browser/prefs/pref_service.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/browser.h" | |
| 11 #include "chrome/browser/ui/browser_list.h" | 9 #include "chrome/browser/ui/browser_list.h" |
| 12 #include "chrome/browser/ui/browser_window.h" | 10 #include "chrome/browser/ui/browser_window.h" |
| 13 #include "chrome/browser/ui/find_bar/find_bar.h" | 11 #include "chrome/browser/ui/find_bar/find_bar.h" |
| 14 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 12 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
| 15 #include "chrome/browser/ui/panels/native_panel.h" | 13 #include "chrome/browser/ui/panels/native_panel.h" |
| 16 #include "chrome/browser/ui/panels/panel.h" | 14 #include "chrome/browser/ui/panels/panel.h" |
| 17 #include "chrome/browser/ui/panels/panel_manager.h" | 15 #include "chrome/browser/ui/panels/panel_manager.h" |
| 18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | |
| 19 #include "chrome/browser/web_applications/web_app.h" | 16 #include "chrome/browser/web_applications/web_app.h" |
| 20 #include "chrome/common/chrome_notification_types.h" | 17 #include "chrome/common/chrome_notification_types.h" |
| 21 #include "chrome/common/chrome_switches.h" | |
| 22 #include "chrome/common/extensions/extension.h" | |
| 23 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
| 24 #include "chrome/test/base/in_process_browser_test.h" | |
| 25 #include "chrome/test/base/ui_test_utils.h" | 19 #include "chrome/test/base/ui_test_utils.h" |
| 26 #include "content/browser/download/download_manager.h" | 20 #include "content/browser/download/download_manager.h" |
| 27 #include "content/browser/net/url_request_mock_http_job.h" | 21 #include "content/browser/net/url_request_mock_http_job.h" |
| 28 #include "content/browser/tab_contents/test_tab_contents.h" | |
| 29 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 30 | 23 |
| 31 #if defined(OS_MACOSX) | 24 class PanelBrowserTest : public BasePanelBrowserTest { |
| 32 #include "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" | |
| 33 #endif | |
| 34 | |
| 35 class PanelBrowserTest : public InProcessBrowserTest { | |
| 36 public: | 25 public: |
| 37 PanelBrowserTest() : InProcessBrowserTest() { | 26 PanelBrowserTest() : BasePanelBrowserTest() { |
| 38 #if defined(OS_MACOSX) | |
| 39 FindBarBridge::disable_animations_during_testing_ = true; | |
| 40 #endif | |
| 41 } | |
| 42 | |
| 43 virtual void SetUpCommandLine(CommandLine* command_line) { | |
| 44 command_line->AppendSwitch(switches::kEnablePanels); | |
| 45 } | 27 } |
| 46 | 28 |
| 47 protected: | 29 protected: |
| 48 Panel* CreatePanel(const std::string& name, const gfx::Rect& bounds) { | |
| 49 // Opening panels on a Mac causes NSWindowController of the Panel window | |
| 50 // to be autoreleased. We need a pool drained after it's done so the test | |
| 51 // can close correctly. The NSWindowController of the Panel window controls | |
| 52 // lifetime of the Browser object so we want to release it as soon as | |
| 53 // possible. In real Chrome, this is done by message pump. | |
| 54 // On non-Mac platform, this is an empty class. | |
| 55 base::mac::ScopedNSAutoreleasePool autorelease_pool; | |
| 56 | |
| 57 Browser* panel_browser = Browser::CreateForApp(Browser::TYPE_PANEL, | |
| 58 name, | |
| 59 bounds, | |
| 60 browser()->profile()); | |
| 61 EXPECT_TRUE(panel_browser->is_type_panel()); | |
| 62 | |
| 63 TabContentsWrapper* tab_contents = | |
| 64 new TabContentsWrapper(new TestTabContents(browser()->profile(), NULL)); | |
| 65 panel_browser->AddTab(tab_contents, PageTransition::LINK); | |
| 66 | |
| 67 Panel* panel = static_cast<Panel*>(panel_browser->window()); | |
| 68 panel->Show(); | |
| 69 MessageLoopForUI::current()->RunAllPending(); | |
| 70 | |
| 71 return panel; | |
| 72 } | |
| 73 | |
| 74 void CloseWindowAndWait(Browser* browser) { | 30 void CloseWindowAndWait(Browser* browser) { |
| 75 // Closing a browser window may involve several async tasks. Need to use | 31 // Closing a browser window may involve several async tasks. Need to use |
| 76 // message pump and wait for the notification. | 32 // message pump and wait for the notification. |
| 77 size_t browser_count = BrowserList::size(); | 33 size_t browser_count = BrowserList::size(); |
| 78 ui_test_utils::WindowedNotificationObserver signal( | 34 ui_test_utils::WindowedNotificationObserver signal( |
| 79 chrome::NOTIFICATION_BROWSER_CLOSED, | 35 chrome::NOTIFICATION_BROWSER_CLOSED, |
| 80 Source<Browser>(browser)); | 36 Source<Browser>(browser)); |
| 81 browser->CloseWindow(); | 37 browser->CloseWindow(); |
| 82 signal.Wait(); | 38 signal.Wait(); |
| 83 // Now we have one less browser instance. | 39 // Now we have one less browser instance. |
| 84 EXPECT_EQ(browser_count - 1, BrowserList::size()); | 40 EXPECT_EQ(browser_count - 1, BrowserList::size()); |
| 85 } | 41 } |
| 86 | 42 |
| 87 // Creates a testing extension. | |
| 88 scoped_refptr<Extension> CreateExtension(const FilePath::StringType& path) { | |
| 89 #if defined(OS_WIN) | |
| 90 FilePath full_path(FILE_PATH_LITERAL("c:\\")); | |
| 91 #else | |
| 92 FilePath full_path(FILE_PATH_LITERAL("/")); | |
| 93 #endif | |
| 94 full_path = full_path.Append(path); | |
| 95 DictionaryValue input_value; | |
| 96 input_value.SetString(extension_manifest_keys::kVersion, "1.0.0.0"); | |
| 97 input_value.SetString(extension_manifest_keys::kName, "Sample Extension"); | |
| 98 std::string error; | |
| 99 scoped_refptr<Extension> extension = Extension::Create( | |
| 100 full_path, Extension::INVALID, input_value, | |
| 101 Extension::STRICT_ERROR_CHECKS, &error); | |
| 102 EXPECT_TRUE(extension.get()); | |
| 103 EXPECT_STREQ("", error.c_str()); | |
| 104 browser()->GetProfile()->GetExtensionService()->OnLoadSingleExtension( | |
| 105 extension.get(), false); | |
| 106 return extension; | |
| 107 } | |
| 108 | |
| 109 void TestCreatePanelOnOverflow() { | 43 void TestCreatePanelOnOverflow() { |
| 110 PanelManager* panel_manager = PanelManager::GetInstance(); | 44 PanelManager* panel_manager = PanelManager::GetInstance(); |
| 111 EXPECT_EQ(0, panel_manager->num_panels()); // No panels initially. | 45 EXPECT_EQ(0, panel_manager->num_panels()); // No panels initially. |
| 112 | 46 |
| 113 // Specify the work area for testing purpose. | |
| 114 panel_manager->SetWorkArea(gfx::Rect(0, 0, 800, 600)); | |
| 115 | |
| 116 // Create testing extensions. | 47 // Create testing extensions. |
| 48 DictionaryValue empty_value; |
| 117 scoped_refptr<Extension> extension1 = | 49 scoped_refptr<Extension> extension1 = |
| 118 CreateExtension(FILE_PATH_LITERAL("extension1")); | 50 CreateExtension(FILE_PATH_LITERAL("extension1"), |
| 51 Extension::INVALID, empty_value); |
| 119 scoped_refptr<Extension> extension2 = | 52 scoped_refptr<Extension> extension2 = |
| 120 CreateExtension(FILE_PATH_LITERAL("extension2")); | 53 CreateExtension(FILE_PATH_LITERAL("extension2"), |
| 54 Extension::INVALID, empty_value); |
| 121 scoped_refptr<Extension> extension3 = | 55 scoped_refptr<Extension> extension3 = |
| 122 CreateExtension(FILE_PATH_LITERAL("extension3")); | 56 CreateExtension(FILE_PATH_LITERAL("extension3"), |
| 57 Extension::INVALID, empty_value); |
| 123 | 58 |
| 124 // First, create 3 panels. | 59 // First, create 3 panels. |
| 125 Panel* panel1 = CreatePanel( | 60 Panel* panel1 = CreatePanelWithBounds( |
| 126 web_app::GenerateApplicationNameFromExtensionId(extension1->id()), | 61 web_app::GenerateApplicationNameFromExtensionId(extension1->id()), |
| 127 gfx::Rect(0, 0, 250, 200)); | 62 gfx::Rect(0, 0, 250, 200)); |
| 128 Panel* panel2 = CreatePanel( | 63 Panel* panel2 = CreatePanelWithBounds( |
| 129 web_app::GenerateApplicationNameFromExtensionId(extension2->id()), | 64 web_app::GenerateApplicationNameFromExtensionId(extension2->id()), |
| 130 gfx::Rect(0, 0, 300, 200)); | 65 gfx::Rect(0, 0, 300, 200)); |
| 131 Panel* panel3 = CreatePanel( | 66 Panel* panel3 = CreatePanelWithBounds( |
| 132 web_app::GenerateApplicationNameFromExtensionId(extension1->id()), | 67 web_app::GenerateApplicationNameFromExtensionId(extension1->id()), |
| 133 gfx::Rect(0, 0, 200, 200)); | 68 gfx::Rect(0, 0, 200, 200)); |
| 134 ASSERT_EQ(3, panel_manager->num_panels()); | 69 ASSERT_EQ(3, panel_manager->num_panels()); |
| 135 | 70 |
| 136 // Test closing the leftmost panel that is from same extension. | 71 // Test closing the leftmost panel that is from same extension. |
| 137 ui_test_utils::WindowedNotificationObserver signal( | 72 ui_test_utils::WindowedNotificationObserver signal( |
| 138 chrome::NOTIFICATION_BROWSER_CLOSED, | 73 chrome::NOTIFICATION_BROWSER_CLOSED, |
| 139 Source<Browser>(panel2->browser())); | 74 Source<Browser>(panel2->browser())); |
| 140 Panel* panel4 = CreatePanel( | 75 Panel* panel4 = CreatePanelWithBounds( |
| 141 web_app::GenerateApplicationNameFromExtensionId(extension2->id()), | 76 web_app::GenerateApplicationNameFromExtensionId(extension2->id()), |
| 142 gfx::Rect(0, 0, 280, 200)); | 77 gfx::Rect(0, 0, 280, 200)); |
| 143 signal.Wait(); | 78 signal.Wait(); |
| 144 ASSERT_EQ(3, panel_manager->num_panels()); | 79 ASSERT_EQ(3, panel_manager->num_panels()); |
| 145 EXPECT_LT(panel4->GetBounds().right(), panel3->GetBounds().x()); | 80 EXPECT_LT(panel4->GetBounds().right(), panel3->GetBounds().x()); |
| 146 EXPECT_LT(panel3->GetBounds().right(), panel1->GetBounds().x()); | 81 EXPECT_LT(panel3->GetBounds().right(), panel1->GetBounds().x()); |
| 147 | 82 |
| 148 // Test closing the leftmost panel. | 83 // Test closing the leftmost panel. |
| 149 ui_test_utils::WindowedNotificationObserver signal2( | 84 ui_test_utils::WindowedNotificationObserver signal2( |
| 150 chrome::NOTIFICATION_BROWSER_CLOSED, | 85 chrome::NOTIFICATION_BROWSER_CLOSED, |
| 151 Source<Browser>(panel4->browser())); | 86 Source<Browser>(panel4->browser())); |
| 152 Panel* panel5 = CreatePanel( | 87 Panel* panel5 = CreatePanelWithBounds( |
| 153 web_app::GenerateApplicationNameFromExtensionId(extension3->id()), | 88 web_app::GenerateApplicationNameFromExtensionId(extension3->id()), |
| 154 gfx::Rect(0, 0, 300, 200)); | 89 gfx::Rect(0, 0, 300, 200)); |
| 155 signal2.Wait(); | 90 signal2.Wait(); |
| 156 ASSERT_EQ(3, panel_manager->num_panels()); | 91 ASSERT_EQ(3, panel_manager->num_panels()); |
| 157 EXPECT_LT(panel5->GetBounds().right(), panel3->GetBounds().x()); | 92 EXPECT_LT(panel5->GetBounds().right(), panel3->GetBounds().x()); |
| 158 EXPECT_LT(panel3->GetBounds().right(), panel1->GetBounds().x()); | 93 EXPECT_LT(panel3->GetBounds().right(), panel1->GetBounds().x()); |
| 159 | 94 |
| 160 // Test closing 2 leftmost panels. | 95 // Test closing 2 leftmost panels. |
| 161 ui_test_utils::WindowedNotificationObserver signal3( | 96 ui_test_utils::WindowedNotificationObserver signal3( |
| 162 chrome::NOTIFICATION_BROWSER_CLOSED, | 97 chrome::NOTIFICATION_BROWSER_CLOSED, |
| 163 Source<Browser>(panel3->browser())); | 98 Source<Browser>(panel3->browser())); |
| 164 ui_test_utils::WindowedNotificationObserver signal4( | 99 ui_test_utils::WindowedNotificationObserver signal4( |
| 165 chrome::NOTIFICATION_BROWSER_CLOSED, | 100 chrome::NOTIFICATION_BROWSER_CLOSED, |
| 166 Source<Browser>(panel5->browser())); | 101 Source<Browser>(panel5->browser())); |
| 167 Panel* panel6 = CreatePanel( | 102 Panel* panel6 = CreatePanelWithBounds( |
| 168 web_app::GenerateApplicationNameFromExtensionId(extension3->id()), | 103 web_app::GenerateApplicationNameFromExtensionId(extension3->id()), |
| 169 gfx::Rect(0, 0, 500, 200)); | 104 gfx::Rect(0, 0, 500, 200)); |
| 170 signal3.Wait(); | 105 signal3.Wait(); |
| 171 signal4.Wait(); | 106 signal4.Wait(); |
| 172 ASSERT_EQ(2, panel_manager->num_panels()); | 107 ASSERT_EQ(2, panel_manager->num_panels()); |
| 173 EXPECT_LT(panel6->GetBounds().right(), panel1->GetBounds().x()); | 108 EXPECT_LT(panel6->GetBounds().right(), panel1->GetBounds().x()); |
| 174 | 109 |
| 175 panel1->Close(); | 110 panel1->Close(); |
| 176 panel6->Close(); | 111 panel6->Close(); |
| 177 } | 112 } |
| 178 | 113 |
| 179 void SetWorkArea(const gfx::Rect& work_area) { | |
| 180 PanelManager::GetInstance()->SetWorkArea(gfx::Rect(0, 0, 800, 600)); | |
| 181 } | |
| 182 | |
| 183 int horizontal_spacing() { | 114 int horizontal_spacing() { |
| 184 return PanelManager::horizontal_spacing(); | 115 return PanelManager::horizontal_spacing(); |
| 185 } | 116 } |
| 186 | 117 |
| 187 std::vector<gfx::Rect> GetAllPanelsBounds() { | 118 std::vector<gfx::Rect> GetAllPanelsBounds() { |
| 188 std::vector<gfx::Rect> panels_bounds; | 119 std::vector<gfx::Rect> panels_bounds; |
| 189 const std::vector<Panel*>& panels = PanelManager::GetInstance()->panels(); | 120 const std::vector<Panel*>& panels = PanelManager::GetInstance()->panels(); |
| 190 for (size_t i = 0; i < panels.size(); ++i) | 121 for (size_t i = 0; i < panels.size(); ++i) |
| 191 panels_bounds.push_back(panels[i]->GetRestoredBounds()); | 122 panels_bounds.push_back(panels[i]->GetRestoredBounds()); |
| 192 return panels_bounds; | 123 return panels_bounds; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 CheckPanelBoundsWithDeltas(panels, test_begin_bounds, | 220 CheckPanelBoundsWithDeltas(panels, test_begin_bounds, |
| 290 expected_delta_x_after_finish); | 221 expected_delta_x_after_finish); |
| 291 } | 222 } |
| 292 } | 223 } |
| 293 }; | 224 }; |
| 294 | 225 |
| 295 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, CreatePanel) { | 226 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, CreatePanel) { |
| 296 PanelManager* panel_manager = PanelManager::GetInstance(); | 227 PanelManager* panel_manager = PanelManager::GetInstance(); |
| 297 EXPECT_EQ(0, panel_manager->num_panels()); // No panels initially. | 228 EXPECT_EQ(0, panel_manager->num_panels()); // No panels initially. |
| 298 | 229 |
| 299 Panel* panel = CreatePanel("PanelTest", gfx::Rect()); | 230 Panel* panel = CreatePanel("PanelTest"); |
| 300 EXPECT_EQ(1, panel_manager->num_panels()); | 231 EXPECT_EQ(1, panel_manager->num_panels()); |
| 301 | 232 |
| 302 gfx::Rect bounds = panel->GetBounds(); | 233 gfx::Rect bounds = panel->GetBounds(); |
| 303 EXPECT_GT(bounds.x(), 0); | 234 EXPECT_GT(bounds.x(), 0); |
| 304 EXPECT_GT(bounds.y(), 0); | 235 EXPECT_GT(bounds.y(), 0); |
| 305 EXPECT_GT(bounds.width(), 0); | 236 EXPECT_GT(bounds.width(), 0); |
| 306 EXPECT_GT(bounds.height(), 0); | 237 EXPECT_GT(bounds.height(), 0); |
| 307 | 238 |
| 308 CloseWindowAndWait(panel->browser()); | 239 CloseWindowAndWait(panel->browser()); |
| 309 | 240 |
| 310 EXPECT_EQ(0, panel_manager->num_panels()); | 241 EXPECT_EQ(0, panel_manager->num_panels()); |
| 311 } | 242 } |
| 312 | 243 |
| 313 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, FindBar) { | 244 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, FindBar) { |
| 314 Panel* panel = CreatePanel("PanelTest", gfx::Rect(0, 0, 400, 400)); | 245 Panel* panel = CreatePanelWithBounds("PanelTest", gfx::Rect(0, 0, 400, 400)); |
| 315 Browser* browser = panel->browser(); | 246 Browser* browser = panel->browser(); |
| 316 browser->ShowFindBar(); | 247 browser->ShowFindBar(); |
| 317 ASSERT_TRUE(browser->GetFindBarController()->find_bar()->IsFindBarVisible()); | 248 ASSERT_TRUE(browser->GetFindBarController()->find_bar()->IsFindBarVisible()); |
| 318 panel->Close(); | 249 panel->Close(); |
| 319 } | 250 } |
| 320 | 251 |
| 321 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, CreatePanelOnOverflow) { | 252 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, CreatePanelOnOverflow) { |
| 322 TestCreatePanelOnOverflow(); | 253 TestCreatePanelOnOverflow(); |
| 323 } | 254 } |
| 324 | 255 |
| 325 #if defined(TOOLKIT_GTK) || defined(OS_WIN) | 256 #if defined(TOOLKIT_GTK) || defined(OS_WIN) |
| 326 #define MAYBE_DragPanels DragPanels | 257 #define MAYBE_DragPanels DragPanels |
| 327 #else | 258 #else |
| 328 #define MAYBE_DragPanels DISABLED_DragPanels | 259 #define MAYBE_DragPanels DISABLED_DragPanels |
| 329 #endif | 260 #endif |
| 330 | 261 |
| 331 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MAYBE_DragPanels) { | 262 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MAYBE_DragPanels) { |
| 332 // Set work area to make the test consistent on different monitor sizes. | |
| 333 SetWorkArea(gfx::Rect(0, 0, 800, 600)); | |
| 334 | |
| 335 static const int max_panels = 3; | 263 static const int max_panels = 3; |
| 336 static const int zero_delta = 0; | 264 static const int zero_delta = 0; |
| 337 static const int small_delta = 10; | 265 static const int small_delta = 10; |
| 338 static const int big_delta = 70; | 266 static const int big_delta = 70; |
| 339 static const int bigger_delta = 120; | 267 static const int bigger_delta = 120; |
| 340 static const int biggest_delta = 200; | 268 static const int biggest_delta = 200; |
| 341 static const std::vector<int> zero_deltas(max_panels, zero_delta); | 269 static const std::vector<int> zero_deltas(max_panels, zero_delta); |
| 342 | 270 |
| 343 std::vector<int> expected_delta_x_after_drag(max_panels, zero_delta); | 271 std::vector<int> expected_delta_x_after_drag(max_panels, zero_delta); |
| 344 std::vector<int> expected_delta_x_after_finish(max_panels, zero_delta); | 272 std::vector<int> expected_delta_x_after_finish(max_panels, zero_delta); |
| 345 std::vector<gfx::Rect> current_bounds; | 273 std::vector<gfx::Rect> current_bounds; |
| 346 std::vector<gfx::Rect> initial_bounds; | 274 std::vector<gfx::Rect> initial_bounds; |
| 347 | 275 |
| 348 // Tests with a single panel. | 276 // Tests with a single panel. |
| 349 { | 277 { |
| 350 CreatePanel("PanelTest1", gfx::Rect(0, 0, 100, 100)); | 278 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100)); |
| 351 | 279 |
| 352 // Drag left. | 280 // Drag left. |
| 353 expected_delta_x_after_drag[0] = -big_delta; | 281 expected_delta_x_after_drag[0] = -big_delta; |
| 354 expected_delta_x_after_finish = zero_deltas; | 282 expected_delta_x_after_finish = zero_deltas; |
| 355 TestDragging(-big_delta, zero_delta, 0, expected_delta_x_after_drag, | 283 TestDragging(-big_delta, zero_delta, 0, expected_delta_x_after_drag, |
| 356 zero_deltas, GetAllPanelsBounds(), | 284 zero_deltas, GetAllPanelsBounds(), |
| 357 DRAG_ACTION_BEGIN | DRAG_ACTION_FINISH); | 285 DRAG_ACTION_BEGIN | DRAG_ACTION_FINISH); |
| 358 | 286 |
| 359 // Drag left and cancel. | 287 // Drag left and cancel. |
| 360 expected_delta_x_after_drag[0] = -big_delta; | 288 expected_delta_x_after_drag[0] = -big_delta; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 378 TestDragging(0, -big_delta, 0, zero_deltas, zero_deltas, | 306 TestDragging(0, -big_delta, 0, zero_deltas, zero_deltas, |
| 379 GetAllPanelsBounds(), DRAG_ACTION_BEGIN | DRAG_ACTION_FINISH); | 307 GetAllPanelsBounds(), DRAG_ACTION_BEGIN | DRAG_ACTION_FINISH); |
| 380 | 308 |
| 381 // Drag down. Expect no movement on drag. | 309 // Drag down. Expect no movement on drag. |
| 382 TestDragging(0, big_delta, 0, zero_deltas, zero_deltas, | 310 TestDragging(0, big_delta, 0, zero_deltas, zero_deltas, |
| 383 GetAllPanelsBounds(), DRAG_ACTION_BEGIN | DRAG_ACTION_FINISH); | 311 GetAllPanelsBounds(), DRAG_ACTION_BEGIN | DRAG_ACTION_FINISH); |
| 384 } | 312 } |
| 385 | 313 |
| 386 // Tests with two panels. | 314 // Tests with two panels. |
| 387 { | 315 { |
| 388 CreatePanel("PanelTest2", gfx::Rect(0, 0, 120, 120)); | 316 CreatePanelWithBounds("PanelTest2", gfx::Rect(0, 0, 120, 120)); |
| 389 | 317 |
| 390 // Drag left, small delta, expect no shuffle. | 318 // Drag left, small delta, expect no shuffle. |
| 391 { | 319 { |
| 392 expected_delta_x_after_drag = zero_deltas; | 320 expected_delta_x_after_drag = zero_deltas; |
| 393 expected_delta_x_after_drag[0] = -small_delta; | 321 expected_delta_x_after_drag[0] = -small_delta; |
| 394 TestDragging(-small_delta, zero_delta, 0, expected_delta_x_after_drag, | 322 TestDragging(-small_delta, zero_delta, 0, expected_delta_x_after_drag, |
| 395 zero_deltas, GetAllPanelsBounds(), | 323 zero_deltas, GetAllPanelsBounds(), |
| 396 DRAG_ACTION_BEGIN | DRAG_ACTION_FINISH); | 324 DRAG_ACTION_BEGIN | DRAG_ACTION_FINISH); |
| 397 | 325 |
| 398 // Drag right panel i.e index 0, towards left, big delta, expect shuffle. | 326 // Drag right panel i.e index 0, towards left, big delta, expect shuffle. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 // As the drag is being canceled, we don't need expected_delta_x_after | 379 // As the drag is being canceled, we don't need expected_delta_x_after |
| 452 // finish. Instead initial_bounds will be used. | 380 // finish. Instead initial_bounds will be used. |
| 453 TestDragging(big_delta, zero_delta, 1, expected_delta_x_after_drag, | 381 TestDragging(big_delta, zero_delta, 1, expected_delta_x_after_drag, |
| 454 zero_deltas, initial_bounds, | 382 zero_deltas, initial_bounds, |
| 455 DRAG_ACTION_BEGIN | DRAG_ACTION_CANCEL); | 383 DRAG_ACTION_BEGIN | DRAG_ACTION_CANCEL); |
| 456 } | 384 } |
| 457 } | 385 } |
| 458 | 386 |
| 459 // Tests with three panels. | 387 // Tests with three panels. |
| 460 { | 388 { |
| 461 CreatePanel("PanelTest3", gfx::Rect(0, 0, 110, 110)); | 389 CreatePanelWithBounds("PanelTest3", gfx::Rect(0, 0, 110, 110)); |
| 462 | 390 |
| 463 // Drag leftmost panel to become rightmost with two shuffles. | 391 // Drag leftmost panel to become rightmost with two shuffles. |
| 464 // We test both shuffles. | 392 // We test both shuffles. |
| 465 { | 393 { |
| 466 // Drag the left-most panel towards right without ending or cancelling it. | 394 // Drag the left-most panel towards right without ending or cancelling it. |
| 467 // Expect shuffle. | 395 // Expect shuffle. |
| 468 initial_bounds = GetAllPanelsBounds(); | 396 initial_bounds = GetAllPanelsBounds(); |
| 469 expected_delta_x_after_drag = zero_deltas; | 397 expected_delta_x_after_drag = zero_deltas; |
| 470 | 398 |
| 471 // Delta for panel being dragged. | 399 // Delta for panel being dragged. |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 EXPECT_EQ(1, tabbed_browser->tab_count()); | 704 EXPECT_EQ(1, tabbed_browser->tab_count()); |
| 777 ASSERT_TRUE(tabbed_browser->window()->IsDownloadShelfVisible()); | 705 ASSERT_TRUE(tabbed_browser->window()->IsDownloadShelfVisible()); |
| 778 tabbed_browser->CloseWindow(); | 706 tabbed_browser->CloseWindow(); |
| 779 #endif | 707 #endif |
| 780 | 708 |
| 781 EXPECT_EQ(1, panel_browser->tab_count()); | 709 EXPECT_EQ(1, panel_browser->tab_count()); |
| 782 ASSERT_FALSE(panel_browser->window()->IsDownloadShelfVisible()); | 710 ASSERT_FALSE(panel_browser->window()->IsDownloadShelfVisible()); |
| 783 | 711 |
| 784 panel_browser->CloseWindow(); | 712 panel_browser->CloseWindow(); |
| 785 } | 713 } |
| OLD | NEW |