| 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/mac/scoped_nsautorelease_pool.h" | 8 #include "base/mac/scoped_nsautorelease_pool.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/panels/panel_manager.h" | 13 #include "chrome/browser/ui/panels/panel_manager.h" |
| 14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 15 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
| 16 #include "chrome/test/base/ui_test_utils.h" |
| 16 #include "content/browser/tab_contents/test_tab_contents.h" | 17 #include "content/browser/tab_contents/test_tab_contents.h" |
| 18 #include "content/common/url_constants.h" |
| 17 | 19 |
| 18 #if defined(OS_MACOSX) | 20 #if defined(OS_MACOSX) |
| 19 #include "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" | 21 #include "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" |
| 20 #endif | 22 #endif |
| 21 | 23 |
| 22 namespace { | 24 namespace { |
| 23 | 25 |
| 24 const int kTestingWorkAreaWidth = 800; | 26 const int kTestingWorkAreaWidth = 800; |
| 25 const int kTestingWorkAreaHeight = 600; | 27 const int kTestingWorkAreaHeight = 600; |
| 26 const int kDefaultAutoHidingDesktopBarThickness = 40; | 28 const int kDefaultAutoHidingDesktopBarThickness = 40; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 kTestingWorkAreaHeight) { | 153 kTestingWorkAreaHeight) { |
| 152 #if defined(OS_MACOSX) | 154 #if defined(OS_MACOSX) |
| 153 FindBarBridge::disable_animations_during_testing_ = true; | 155 FindBarBridge::disable_animations_during_testing_ = true; |
| 154 #endif | 156 #endif |
| 155 } | 157 } |
| 156 | 158 |
| 157 BasePanelBrowserTest::~BasePanelBrowserTest() { | 159 BasePanelBrowserTest::~BasePanelBrowserTest() { |
| 158 } | 160 } |
| 159 | 161 |
| 160 void BasePanelBrowserTest::SetUpCommandLine(CommandLine* command_line) { | 162 void BasePanelBrowserTest::SetUpCommandLine(CommandLine* command_line) { |
| 163 EnableDOMAutomation(); |
| 161 command_line->AppendSwitch(switches::kEnablePanels); | 164 command_line->AppendSwitch(switches::kEnablePanels); |
| 162 } | 165 } |
| 163 | 166 |
| 164 void BasePanelBrowserTest::SetUpOnMainThread() { | 167 void BasePanelBrowserTest::SetUpOnMainThread() { |
| 165 InProcessBrowserTest::SetUpOnMainThread(); | 168 InProcessBrowserTest::SetUpOnMainThread(); |
| 166 | 169 |
| 167 // Setup the work area and desktop bar so that we have consistent testing | 170 // Setup the work area and desktop bar so that we have consistent testing |
| 168 // environment for all panel related tests. | 171 // environment for all panel related tests. |
| 169 PanelManager* panel_manager = PanelManager::GetInstance(); | 172 PanelManager* panel_manager = PanelManager::GetInstance(); |
| 170 mock_auto_hiding_desktop_bar_ = new MockAutoHidingDesktopBarImpl( | 173 mock_auto_hiding_desktop_bar_ = new MockAutoHidingDesktopBarImpl( |
| 171 panel_manager); | 174 panel_manager); |
| 172 panel_manager->set_auto_hiding_desktop_bar(mock_auto_hiding_desktop_bar_); | 175 panel_manager->set_auto_hiding_desktop_bar(mock_auto_hiding_desktop_bar_); |
| 173 panel_manager->SetWorkAreaForTesting(testing_work_area_); | 176 panel_manager->SetWorkAreaForTesting(testing_work_area_); |
| 177 panel_manager->enable_auto_sizing(false); |
| 174 } | 178 } |
| 175 | 179 |
| 176 Panel* BasePanelBrowserTest::CreatePanelWithParams( | 180 Panel* BasePanelBrowserTest::CreatePanelWithParams( |
| 177 const CreatePanelParams& params) { | 181 const CreatePanelParams& params) { |
| 178 // Opening panels on a Mac causes NSWindowController of the Panel window | 182 // Opening panels on a Mac causes NSWindowController of the Panel window |
| 179 // to be autoreleased. We need a pool drained after it's done so the test | 183 // to be autoreleased. We need a pool drained after it's done so the test |
| 180 // can close correctly. The NSWindowController of the Panel window controls | 184 // can close correctly. The NSWindowController of the Panel window controls |
| 181 // lifetime of the Browser object so we want to release it as soon as | 185 // lifetime of the Browser object so we want to release it as soon as |
| 182 // possible. In real Chrome, this is done by message pump. | 186 // possible. In real Chrome, this is done by message pump. |
| 183 // On non-Mac platform, this is an empty class. | 187 // On non-Mac platform, this is an empty class. |
| 184 base::mac::ScopedNSAutoreleasePool autorelease_pool; | 188 base::mac::ScopedNSAutoreleasePool autorelease_pool; |
| 185 | 189 |
| 186 Browser* panel_browser = Browser::CreateForApp(Browser::TYPE_PANEL, | 190 Browser* panel_browser = Browser::CreateForApp(Browser::TYPE_PANEL, |
| 187 params.name, | 191 params.name, |
| 188 params.bounds, | 192 params.bounds, |
| 189 browser()->profile()); | 193 browser()->profile()); |
| 190 EXPECT_TRUE(panel_browser->is_type_panel()); | 194 EXPECT_TRUE(panel_browser->is_type_panel()); |
| 191 | 195 |
| 192 TabContentsWrapper* tab_contents = | 196 if (params.url.is_empty()) { |
| 193 new TabContentsWrapper(new TestTabContents(browser()->profile(), NULL)); | 197 TabContentsWrapper* tab_contents = |
| 194 panel_browser->AddTab(tab_contents, PageTransition::LINK); | 198 new TabContentsWrapper(new TestTabContents(browser()->profile(), NULL)); |
| 199 panel_browser->AddTab(tab_contents, PageTransition::LINK); |
| 200 } else { |
| 201 panel_browser->AddSelectedTabWithURL(params.url, |
| 202 PageTransition::START_PAGE); |
| 203 ui_test_utils::WaitForNavigation( |
| 204 &panel_browser->GetSelectedTabContents()->controller()); |
| 205 } |
| 195 | 206 |
| 196 Panel* panel = static_cast<Panel*>(panel_browser->window()); | 207 Panel* panel = static_cast<Panel*>(panel_browser->window()); |
| 197 if (params.show_flag == SHOW_AS_ACTIVE) | 208 if (params.show_flag == SHOW_AS_ACTIVE) |
| 198 panel->Show(); | 209 panel->Show(); |
| 199 else | 210 else |
| 200 panel->ShowInactive(); | 211 panel->ShowInactive(); |
| 201 MessageLoopForUI::current()->RunAllPending(); | 212 MessageLoopForUI::current()->RunAllPending(); |
| 202 | 213 |
| 203 return panel; | 214 return panel; |
| 204 } | 215 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 232 std::string error; | 243 std::string error; |
| 233 scoped_refptr<Extension> extension = Extension::Create( | 244 scoped_refptr<Extension> extension = Extension::Create( |
| 234 full_path, location, *input_value, | 245 full_path, location, *input_value, |
| 235 Extension::STRICT_ERROR_CHECKS, &error); | 246 Extension::STRICT_ERROR_CHECKS, &error); |
| 236 EXPECT_TRUE(extension.get()); | 247 EXPECT_TRUE(extension.get()); |
| 237 EXPECT_STREQ("", error.c_str()); | 248 EXPECT_STREQ("", error.c_str()); |
| 238 browser()->GetProfile()->GetExtensionService()->OnLoadSingleExtension( | 249 browser()->GetProfile()->GetExtensionService()->OnLoadSingleExtension( |
| 239 extension.get(), false); | 250 extension.get(), false); |
| 240 return extension; | 251 return extension; |
| 241 } | 252 } |
| OLD | NEW |