| 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 "chrome/browser/ui/panels/base_panel_browser_test.h" | 5 #include "chrome/browser/ui/panels/base_panel_browser_test.h" |
| 6 | 6 |
| 7 #include "chrome/browser/ui/browser_list.h" | 7 #include "chrome/browser/ui/browser_list.h" |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 14 #include "base/string_number_conversions.h" |
| 14 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/panels/native_panel.h" | 18 #include "chrome/browser/ui/panels/native_panel.h" |
| 18 #include "chrome/browser/ui/panels/panel_manager.h" | 19 #include "chrome/browser/ui/panels/panel_manager.h" |
| 20 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" |
| 19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 21 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 20 #include "chrome/common/chrome_paths.h" | 22 #include "chrome/common/chrome_paths.h" |
| 21 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
| 22 #include "chrome/common/string_ordinal.h" | 24 #include "chrome/common/string_ordinal.h" |
| 23 #include "chrome/test/base/ui_test_utils.h" | 25 #include "chrome/test/base/ui_test_utils.h" |
| 24 #include "content/browser/tab_contents/test_tab_contents.h" | 26 #include "content/browser/tab_contents/test_tab_contents.h" |
| 25 #include "content/public/browser/notification_service.h" | 27 #include "content/public/browser/notification_service.h" |
| 26 #include "content/public/common/url_constants.h" | 28 #include "content/public/common/url_constants.h" |
| 27 | 29 |
| 28 #if defined(OS_MACOSX) | 30 #if defined(OS_MACOSX) |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 AutoHidingDesktopBar::Alignment alignment, | 147 AutoHidingDesktopBar::Alignment alignment, |
| 146 AutoHidingDesktopBar::Visibility visibility) { | 148 AutoHidingDesktopBar::Visibility visibility) { |
| 147 observer_->OnAutoHidingDesktopBarVisibilityChanged(alignment, visibility); | 149 observer_->OnAutoHidingDesktopBarVisibilityChanged(alignment, visibility); |
| 148 } | 150 } |
| 149 | 151 |
| 150 void MockAutoHidingDesktopBarImpl::NotifyThicknessChange() { | 152 void MockAutoHidingDesktopBarImpl::NotifyThicknessChange() { |
| 151 observer_->OnAutoHidingDesktopBarThicknessChanged(); | 153 observer_->OnAutoHidingDesktopBarThicknessChanged(); |
| 152 } | 154 } |
| 153 | 155 |
| 154 bool ExistsPanel(Panel* panel) { | 156 bool ExistsPanel(Panel* panel) { |
| 155 const PanelManager::Panels& panels = PanelManager::GetInstance()->panels(); | 157 std::vector<Panel*> panels = PanelManager::GetInstance()->panels(); |
| 156 return find(panels.begin(), panels.end(), panel) != panels.end(); | 158 return find(panels.begin(), panels.end(), panel) != panels.end(); |
| 157 } | 159 } |
| 158 | 160 |
| 159 } // namespace | 161 } // namespace |
| 160 | 162 |
| 161 const FilePath::CharType* BasePanelBrowserTest::kTestDir = | 163 const FilePath::CharType* BasePanelBrowserTest::kTestDir = |
| 162 FILE_PATH_LITERAL("panels"); | 164 FILE_PATH_LITERAL("panels"); |
| 163 | 165 |
| 164 BasePanelBrowserTest::BasePanelBrowserTest() | 166 BasePanelBrowserTest::BasePanelBrowserTest() |
| 165 : InProcessBrowserTest(), | 167 : InProcessBrowserTest(), |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 MessageLoopForUI::current()->RunAllPending(); | 320 MessageLoopForUI::current()->RunAllPending(); |
| 319 // Restore focus where it was. It will deactivate the new panel. | 321 // Restore focus where it was. It will deactivate the new panel. |
| 320 last_active_browser->window()->Activate(); | 322 last_active_browser->window()->Activate(); |
| 321 } else { | 323 } else { |
| 322 panel->ShowInactive(); | 324 panel->ShowInactive(); |
| 323 } | 325 } |
| 324 #else | 326 #else |
| 325 panel->ShowInactive(); | 327 panel->ShowInactive(); |
| 326 #endif | 328 #endif |
| 327 } | 329 } |
| 328 MessageLoopForUI::current()->RunAllPending(); | |
| 329 // More waiting, because gaining or losing focus may require inter-process | |
| 330 // asynchronous communication, and it is not enough to just run the local | |
| 331 // message loop to make sure this activity has completed. | |
| 332 WaitForPanelActiveState(panel, params.show_flag); | |
| 333 | 330 |
| 334 // On Linux, window size is not available right away and we should wait | 331 if (params.wait_for_fully_created) { |
| 335 // before moving forward with the test. | 332 MessageLoopForUI::current()->RunAllPending(); |
| 336 WaitForWindowSizeAvailable(panel); | 333 // More waiting, because gaining or losing focus may require inter-process |
| 334 // asynchronous communication, and it is not enough to just run the local |
| 335 // message loop to make sure this activity has completed. |
| 336 WaitForPanelActiveState(panel, params.show_flag); |
| 337 | 337 |
| 338 // Wait for the bounds animations on creation to finish. | 338 // On Linux, window size is not available right away and we should wait |
| 339 WaitForBoundsAnimationFinished(panel); | 339 // before moving forward with the test. |
| 340 WaitForWindowSizeAvailable(panel); |
| 341 |
| 342 // Wait for the bounds animations on creation to finish. |
| 343 WaitForBoundsAnimationFinished(panel); |
| 344 } |
| 340 | 345 |
| 341 return panel; | 346 return panel; |
| 342 } | 347 } |
| 343 | 348 |
| 344 Panel* BasePanelBrowserTest::CreatePanelWithBounds( | 349 Panel* BasePanelBrowserTest::CreatePanelWithBounds( |
| 345 const std::string& panel_name, const gfx::Rect& bounds) { | 350 const std::string& panel_name, const gfx::Rect& bounds) { |
| 346 CreatePanelParams params(panel_name, bounds, SHOW_AS_ACTIVE); | 351 CreatePanelParams params(panel_name, bounds, SHOW_AS_ACTIVE); |
| 347 return CreatePanelWithParams(params); | 352 return CreatePanelWithParams(params); |
| 348 } | 353 } |
| 349 | 354 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 376 std::string error; | 381 std::string error; |
| 377 scoped_refptr<Extension> extension = Extension::Create( | 382 scoped_refptr<Extension> extension = Extension::Create( |
| 378 full_path, location, *input_value, | 383 full_path, location, *input_value, |
| 379 Extension::STRICT_ERROR_CHECKS, &error); | 384 Extension::STRICT_ERROR_CHECKS, &error); |
| 380 EXPECT_TRUE(extension.get()); | 385 EXPECT_TRUE(extension.get()); |
| 381 EXPECT_STREQ("", error.c_str()); | 386 EXPECT_STREQ("", error.c_str()); |
| 382 browser()->GetProfile()->GetExtensionService()-> | 387 browser()->GetProfile()->GetExtensionService()-> |
| 383 OnExtensionInstalled(extension.get(), false, StringOrdinal()); | 388 OnExtensionInstalled(extension.get(), false, StringOrdinal()); |
| 384 return extension; | 389 return extension; |
| 385 } | 390 } |
| 391 |
| 392 void BasePanelBrowserTest::CloseWindowAndWait(Browser* browser) { |
| 393 // Closing a browser window may involve several async tasks. Need to use |
| 394 // message pump and wait for the notification. |
| 395 size_t browser_count = BrowserList::size(); |
| 396 ui_test_utils::WindowedNotificationObserver signal( |
| 397 chrome::NOTIFICATION_BROWSER_CLOSED, |
| 398 content::Source<Browser>(browser)); |
| 399 browser->CloseWindow(); |
| 400 signal.Wait(); |
| 401 // Now we have one less browser instance. |
| 402 EXPECT_EQ(browser_count - 1, BrowserList::size()); |
| 403 } |
| 404 |
| 405 void BasePanelBrowserTest::MoveMouse(const gfx::Point& position) { |
| 406 PanelManager::GetInstance()->mouse_watcher()->NotifyMouseMovement(position); |
| 407 } |
| 408 |
| 409 std::string BasePanelBrowserTest::MakePanelName(int index) { |
| 410 std::string panel_name("Panel"); |
| 411 return panel_name + base::IntToString(index); |
| 412 } |
| OLD | NEW |