Chromium Code Reviews| 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/test/base/ui_test_utils.h" | 24 #include "chrome/test/base/ui_test_utils.h" |
| 23 #include "content/browser/tab_contents/test_tab_contents.h" | 25 #include "content/browser/tab_contents/test_tab_contents.h" |
| 24 #include "content/public/browser/notification_service.h" | 26 #include "content/public/browser/notification_service.h" |
| 25 #include "content/public/common/url_constants.h" | 27 #include "content/public/common/url_constants.h" |
| 26 | 28 |
| 27 #if defined(OS_MACOSX) | 29 #if defined(OS_MACOSX) |
| 28 #include "base/mac/scoped_nsautorelease_pool.h" | 30 #include "base/mac/scoped_nsautorelease_pool.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 AutoHidingDesktopBar::Alignment alignment, | 146 AutoHidingDesktopBar::Alignment alignment, |
| 145 AutoHidingDesktopBar::Visibility visibility) { | 147 AutoHidingDesktopBar::Visibility visibility) { |
| 146 observer_->OnAutoHidingDesktopBarVisibilityChanged(alignment, visibility); | 148 observer_->OnAutoHidingDesktopBarVisibilityChanged(alignment, visibility); |
| 147 } | 149 } |
| 148 | 150 |
| 149 void MockAutoHidingDesktopBarImpl::NotifyThicknessChange() { | 151 void MockAutoHidingDesktopBarImpl::NotifyThicknessChange() { |
| 150 observer_->OnAutoHidingDesktopBarThicknessChanged(); | 152 observer_->OnAutoHidingDesktopBarThicknessChanged(); |
| 151 } | 153 } |
| 152 | 154 |
| 153 bool ExistsPanel(Panel* panel) { | 155 bool ExistsPanel(Panel* panel) { |
| 154 const PanelManager::Panels& panels = PanelManager::GetInstance()->panels(); | 156 std::vector<Panel*> panels = PanelManager::GetInstance()->panels(); |
| 155 return find(panels.begin(), panels.end(), panel) != panels.end(); | 157 return find(panels.begin(), panels.end(), panel) != panels.end(); |
| 156 } | 158 } |
| 157 | 159 |
| 158 } // namespace | 160 } // namespace |
| 159 | 161 |
| 160 const FilePath::CharType* BasePanelBrowserTest::kTestDir = | 162 const FilePath::CharType* BasePanelBrowserTest::kTestDir = |
| 161 FILE_PATH_LITERAL("panels"); | 163 FILE_PATH_LITERAL("panels"); |
| 162 | 164 |
| 163 BasePanelBrowserTest::BasePanelBrowserTest() | 165 BasePanelBrowserTest::BasePanelBrowserTest() |
| 164 : InProcessBrowserTest(), | 166 : InProcessBrowserTest(), |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 372 std::string error; | 374 std::string error; |
| 373 scoped_refptr<Extension> extension = Extension::Create( | 375 scoped_refptr<Extension> extension = Extension::Create( |
| 374 full_path, location, *input_value, | 376 full_path, location, *input_value, |
| 375 Extension::STRICT_ERROR_CHECKS, &error); | 377 Extension::STRICT_ERROR_CHECKS, &error); |
| 376 EXPECT_TRUE(extension.get()); | 378 EXPECT_TRUE(extension.get()); |
| 377 EXPECT_STREQ("", error.c_str()); | 379 EXPECT_STREQ("", error.c_str()); |
| 378 browser()->GetProfile()->GetExtensionService()-> | 380 browser()->GetProfile()->GetExtensionService()-> |
| 379 OnExtensionInstalled(extension.get(), false, -1); | 381 OnExtensionInstalled(extension.get(), false, -1); |
| 380 return extension; | 382 return extension; |
| 381 } | 383 } |
| 384 | |
| 385 void BasePanelBrowserTest::CloseWindowAndWait(Browser* browser) { | |
| 386 // Closing a browser window may involve several async tasks. Need to use | |
| 387 // message pump and wait for the notification. | |
| 388 size_t browser_count = BrowserList::size(); | |
| 389 ui_test_utils::WindowedNotificationObserver signal( | |
| 390 chrome::NOTIFICATION_BROWSER_CLOSED, | |
| 391 content::Source<Browser>(browser)); | |
| 392 browser->CloseWindow(); | |
| 393 signal.Wait(); | |
| 394 // Now we have one less browser instance. | |
| 395 EXPECT_EQ(browser_count - 1, BrowserList::size()); | |
| 396 } | |
| 397 | |
| 398 void BasePanelBrowserTest::MoveMouse(const gfx::Point& position) { | |
| 399 PanelManager::GetInstance()->mouse_watcher()->NotifyMouseMovement(position); | |
| 400 MessageLoopForUI::current()->RunAllPending(); | |
|
jennb
2011/12/10 00:42:46
Think we don't really need RunAllPending here as e
jianli
2011/12/13 23:23:40
Done.
| |
| 401 } | |
| 402 | |
| 403 std::string BasePanelBrowserTest::GetPanelName(int index) { | |
|
jennb
2011/12/10 00:42:46
MakePanelName?
jianli
2011/12/13 23:23:40
Done.
| |
| 404 std::string panel_name("Panel"); | |
| 405 return panel_name + base::IntToString(index); | |
| 406 } | |
| OLD | NEW |