OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/old_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 "base/string_number_conversions.h" |
15 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 const gfx::Rect kTestingPrimaryScreenArea = gfx::Rect(0, 0, 800, 600); | 48 const gfx::Rect kTestingPrimaryScreenArea = gfx::Rect(0, 0, 800, 600); |
49 const gfx::Rect kTestingWorkArea = gfx::Rect(0, 0, 800, 580); | 49 const gfx::Rect kTestingWorkArea = gfx::Rect(0, 0, 800, 580); |
50 | 50 |
51 struct MockDesktopBar { | 51 struct MockDesktopBar { |
52 bool auto_hiding_enabled; | 52 bool auto_hiding_enabled; |
53 DisplaySettingsProvider::DesktopBarVisibility visibility; | 53 DisplaySettingsProvider::DesktopBarVisibility visibility; |
54 int thickness; | 54 int thickness; |
55 }; | 55 }; |
56 | 56 |
57 class MockDisplaySettingsProviderImpl : | 57 class MockDisplaySettingsProviderImpl : |
58 public BasePanelBrowserTest::MockDisplaySettingsProvider { | 58 public OldBasePanelBrowserTest::MockDisplaySettingsProvider { |
59 public: | 59 public: |
60 explicit MockDisplaySettingsProviderImpl(PanelManager* panel_manager); | 60 explicit MockDisplaySettingsProviderImpl(PanelManager* panel_manager); |
61 virtual ~MockDisplaySettingsProviderImpl() { } | 61 virtual ~MockDisplaySettingsProviderImpl() { } |
62 | 62 |
63 // Overridden from DisplaySettingsProvider: | 63 // Overridden from DisplaySettingsProvider: |
64 virtual gfx::Rect GetPrimaryScreenArea() const OVERRIDE; | 64 virtual gfx::Rect GetPrimaryScreenArea() const OVERRIDE; |
65 virtual gfx::Rect GetWorkArea() const OVERRIDE; | 65 virtual gfx::Rect GetWorkArea() const OVERRIDE; |
66 virtual bool IsAutoHidingDesktopBarEnabled( | 66 virtual bool IsAutoHidingDesktopBarEnabled( |
67 DesktopBarAlignment alignment) OVERRIDE; | 67 DesktopBarAlignment alignment) OVERRIDE; |
68 virtual int GetDesktopBarThickness( | 68 virtual int GetDesktopBarThickness( |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 OnAutoHidingDesktopBarChanged(); | 180 OnAutoHidingDesktopBarChanged(); |
181 } | 181 } |
182 | 182 |
183 bool ExistsPanel(Panel* panel) { | 183 bool ExistsPanel(Panel* panel) { |
184 std::vector<Panel*> panels = PanelManager::GetInstance()->panels(); | 184 std::vector<Panel*> panels = PanelManager::GetInstance()->panels(); |
185 return std::find(panels.begin(), panels.end(), panel) != panels.end(); | 185 return std::find(panels.begin(), panels.end(), panel) != panels.end(); |
186 } | 186 } |
187 | 187 |
188 } // namespace | 188 } // namespace |
189 | 189 |
190 const FilePath::CharType* BasePanelBrowserTest::kTestDir = | 190 const FilePath::CharType* OldBasePanelBrowserTest::kTestDir = |
191 FILE_PATH_LITERAL("panels"); | 191 FILE_PATH_LITERAL("panels"); |
192 | 192 |
193 BasePanelBrowserTest::BasePanelBrowserTest() | 193 OldBasePanelBrowserTest::OldBasePanelBrowserTest() |
194 : InProcessBrowserTest(), | 194 : InProcessBrowserTest(), |
195 mock_display_settings_enabled_(true) { | 195 mock_display_settings_enabled_(true) { |
196 #if defined(OS_MACOSX) | 196 #if defined(OS_MACOSX) |
197 FindBarBridge::disable_animations_during_testing_ = true; | 197 FindBarBridge::disable_animations_during_testing_ = true; |
198 #endif | 198 #endif |
199 } | 199 } |
200 | 200 |
201 BasePanelBrowserTest::~BasePanelBrowserTest() { | 201 OldBasePanelBrowserTest::~OldBasePanelBrowserTest() { |
202 } | 202 } |
203 | 203 |
204 bool BasePanelBrowserTest::SkipTestIfIceWM() { | 204 bool OldBasePanelBrowserTest::SkipTestIfIceWM() { |
205 #if defined(OS_LINUX) | 205 #if defined(OS_LINUX) |
206 return ui::GuessWindowManager() == ui::WM_ICE_WM; | 206 return ui::GuessWindowManager() == ui::WM_ICE_WM; |
207 #else | 207 #else |
208 return false; | 208 return false; |
209 #endif | 209 #endif |
210 } | 210 } |
211 | 211 |
212 bool BasePanelBrowserTest::SkipTestIfCompizWM() { | 212 bool OldBasePanelBrowserTest::SkipTestIfCompizWM() { |
213 #if defined(OS_LINUX) | 213 #if defined(OS_LINUX) |
214 return ui::GuessWindowManager() == ui::WM_COMPIZ; | 214 return ui::GuessWindowManager() == ui::WM_COMPIZ; |
215 #else | 215 #else |
216 return false; | 216 return false; |
217 #endif | 217 #endif |
218 } | 218 } |
219 | 219 |
220 void BasePanelBrowserTest::SetUpCommandLine(CommandLine* command_line) { | 220 void OldBasePanelBrowserTest::SetUpCommandLine(CommandLine* command_line) { |
221 EnableDOMAutomation(); | 221 EnableDOMAutomation(); |
222 command_line->AppendSwitch(switches::kEnablePanels); | 222 command_line->AppendSwitch(switches::kEnablePanels); |
223 } | 223 } |
224 | 224 |
225 void BasePanelBrowserTest::SetUpOnMainThread() { | 225 void OldBasePanelBrowserTest::SetUpOnMainThread() { |
226 InProcessBrowserTest::SetUpOnMainThread(); | 226 InProcessBrowserTest::SetUpOnMainThread(); |
227 | 227 |
228 // Setup the work area and desktop bar so that we have consistent testing | 228 // Setup the work area and desktop bar so that we have consistent testing |
229 // environment for all panel related tests. | 229 // environment for all panel related tests. |
230 PanelManager* panel_manager = PanelManager::GetInstance(); | 230 PanelManager* panel_manager = PanelManager::GetInstance(); |
231 if (mock_display_settings_enabled_) { | 231 if (mock_display_settings_enabled_) { |
232 mock_display_settings_provider_ = | 232 mock_display_settings_provider_ = |
233 new MockDisplaySettingsProviderImpl(panel_manager); | 233 new MockDisplaySettingsProviderImpl(panel_manager); |
234 SetTestingAreas(kTestingPrimaryScreenArea, kTestingWorkArea); | 234 SetTestingAreas(kTestingPrimaryScreenArea, kTestingWorkArea); |
235 } | 235 } |
236 | 236 |
237 panel_manager->enable_auto_sizing(false); | 237 panel_manager->enable_auto_sizing(false); |
238 | 238 |
239 PanelManager::shorten_time_intervals_for_testing(); | 239 PanelManager::shorten_time_intervals_for_testing(); |
240 | 240 |
241 // This is needed so the subsequently created panels can be activated. | 241 // This is needed so the subsequently created panels can be activated. |
242 // On a Mac, it transforms background-only test process into foreground one. | 242 // On a Mac, it transforms background-only test process into foreground one. |
243 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 243 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
244 } | 244 } |
245 | 245 |
246 void BasePanelBrowserTest::WaitForPanelActiveState( | 246 void OldBasePanelBrowserTest::WaitForPanelActiveState( |
247 Panel* panel, ActiveState expected_state) { | 247 Panel* panel, ActiveState expected_state) { |
248 DCHECK(expected_state == SHOW_AS_ACTIVE || | 248 DCHECK(expected_state == SHOW_AS_ACTIVE || |
249 expected_state == SHOW_AS_INACTIVE); | 249 expected_state == SHOW_AS_INACTIVE); |
250 ui_test_utils::WindowedNotificationObserver signal( | 250 ui_test_utils::WindowedNotificationObserver signal( |
251 chrome::NOTIFICATION_PANEL_CHANGED_ACTIVE_STATUS, | 251 chrome::NOTIFICATION_PANEL_CHANGED_ACTIVE_STATUS, |
252 content::Source<Panel>(panel)); | 252 content::Source<Panel>(panel)); |
253 if (panel->IsActive() == (expected_state == SHOW_AS_ACTIVE)) | 253 if (panel->IsActive() == (expected_state == SHOW_AS_ACTIVE)) |
254 return; // Already in required state. | 254 return; // Already in required state. |
255 signal.Wait(); | 255 signal.Wait(); |
256 // Verify that transition happened in the desired direction. | 256 // Verify that transition happened in the desired direction. |
257 EXPECT_TRUE(panel->IsActive() == (expected_state == SHOW_AS_ACTIVE)); | 257 EXPECT_TRUE(panel->IsActive() == (expected_state == SHOW_AS_ACTIVE)); |
258 } | 258 } |
259 | 259 |
260 void BasePanelBrowserTest::WaitForWindowSizeAvailable(Panel* panel) { | 260 void OldBasePanelBrowserTest::WaitForWindowSizeAvailable(Panel* panel) { |
261 scoped_ptr<NativePanelTesting> panel_testing( | 261 scoped_ptr<NativePanelTesting> panel_testing( |
262 NativePanelTesting::Create(panel->native_panel())); | 262 NativePanelTesting::Create(panel->native_panel())); |
263 ui_test_utils::WindowedNotificationObserver signal( | 263 ui_test_utils::WindowedNotificationObserver signal( |
264 chrome::NOTIFICATION_PANEL_WINDOW_SIZE_KNOWN, | 264 chrome::NOTIFICATION_PANEL_WINDOW_SIZE_KNOWN, |
265 content::Source<Panel>(panel)); | 265 content::Source<Panel>(panel)); |
266 if (panel_testing->IsWindowSizeKnown()) | 266 if (panel_testing->IsWindowSizeKnown()) |
267 return; | 267 return; |
268 signal.Wait(); | 268 signal.Wait(); |
269 EXPECT_TRUE(panel_testing->IsWindowSizeKnown()); | 269 EXPECT_TRUE(panel_testing->IsWindowSizeKnown()); |
270 } | 270 } |
271 | 271 |
272 void BasePanelBrowserTest::WaitForBoundsAnimationFinished(Panel* panel) { | 272 void OldBasePanelBrowserTest::WaitForBoundsAnimationFinished(Panel* panel) { |
273 scoped_ptr<NativePanelTesting> panel_testing( | 273 scoped_ptr<NativePanelTesting> panel_testing( |
274 NativePanelTesting::Create(panel->native_panel())); | 274 NativePanelTesting::Create(panel->native_panel())); |
275 ui_test_utils::WindowedNotificationObserver signal( | 275 ui_test_utils::WindowedNotificationObserver signal( |
276 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, | 276 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, |
277 content::Source<Panel>(panel)); | 277 content::Source<Panel>(panel)); |
278 if (!panel_testing->IsAnimatingBounds()) | 278 if (!panel_testing->IsAnimatingBounds()) |
279 return; | 279 return; |
280 signal.Wait(); | 280 signal.Wait(); |
281 EXPECT_TRUE(!panel_testing->IsAnimatingBounds()); | 281 EXPECT_TRUE(!panel_testing->IsAnimatingBounds()); |
282 } | 282 } |
283 | 283 |
284 void BasePanelBrowserTest::WaitForExpansionStateChanged( | 284 void OldBasePanelBrowserTest::WaitForExpansionStateChanged( |
285 Panel* panel, Panel::ExpansionState expansion_state) { | 285 Panel* panel, Panel::ExpansionState expansion_state) { |
286 ui_test_utils::WindowedNotificationObserver signal( | 286 ui_test_utils::WindowedNotificationObserver signal( |
287 chrome::NOTIFICATION_PANEL_CHANGED_EXPANSION_STATE, | 287 chrome::NOTIFICATION_PANEL_CHANGED_EXPANSION_STATE, |
288 content::Source<Panel>(panel)); | 288 content::Source<Panel>(panel)); |
289 if (panel->expansion_state() == expansion_state) | 289 if (panel->expansion_state() == expansion_state) |
290 return; | 290 return; |
291 signal.Wait(); | 291 signal.Wait(); |
292 EXPECT_EQ(expansion_state, panel->expansion_state()); | 292 EXPECT_EQ(expansion_state, panel->expansion_state()); |
293 } | 293 } |
294 | 294 |
295 Panel* BasePanelBrowserTest::CreatePanelWithParams( | 295 Panel* OldBasePanelBrowserTest::CreatePanelWithParams( |
296 const CreatePanelParams& params) { | 296 const CreatePanelParams& params) { |
297 #if defined(OS_MACOSX) | 297 #if defined(OS_MACOSX) |
298 // Opening panels on a Mac causes NSWindowController of the Panel window | 298 // Opening panels on a Mac causes NSWindowController of the Panel window |
299 // to be autoreleased. We need a pool drained after it's done so the test | 299 // to be autoreleased. We need a pool drained after it's done so the test |
300 // can close correctly. The NSWindowController of the Panel window controls | 300 // can close correctly. The NSWindowController of the Panel window controls |
301 // lifetime of the Browser object so we want to release it as soon as | 301 // lifetime of the Browser object so we want to release it as soon as |
302 // possible. In real Chrome, this is done by message pump. | 302 // possible. In real Chrome, this is done by message pump. |
303 // On non-Mac platform, this is an empty class. | 303 // On non-Mac platform, this is an empty class. |
304 base::mac::ScopedNSAutoreleasePool autorelease_pool; | 304 base::mac::ScopedNSAutoreleasePool autorelease_pool; |
305 #endif | 305 #endif |
(...skipping 17 matching lines...) Expand all Loading... |
323 static_cast<PanelBrowserWindow*>(panel_browser->window()); | 323 static_cast<PanelBrowserWindow*>(panel_browser->window()); |
324 Panel* panel = panel_browser_window->panel(); | 324 Panel* panel = panel_browser_window->panel(); |
325 | 325 |
326 if (!PanelManager::GetInstance()->auto_sizing_enabled() || | 326 if (!PanelManager::GetInstance()->auto_sizing_enabled() || |
327 params.bounds.width() || params.bounds.height()) { | 327 params.bounds.width() || params.bounds.height()) { |
328 EXPECT_FALSE(panel->auto_resizable()); | 328 EXPECT_FALSE(panel->auto_resizable()); |
329 } else { | 329 } else { |
330 EXPECT_TRUE(panel->auto_resizable()); | 330 EXPECT_TRUE(panel->auto_resizable()); |
331 } | 331 } |
332 | 332 |
333 #if defined(OS_LINUX) | |
334 // On bots, we might have a simple window manager which always activates new | |
335 // windows, and can't always deactivate them. Keep track of the previously | |
336 // active window so we can activate that window back to ensure the new window | |
337 // is inactive. | |
338 Browser* last_active_browser_to_restore = NULL; | |
339 if (params.expected_active_state == SHOW_AS_INACTIVE && | |
340 ui::GuessWindowManager() == ui::WM_ICE_WM) { | |
341 last_active_browser_to_restore = BrowserList::GetLastActive(); | |
342 EXPECT_TRUE(last_active_browser_to_restore); | |
343 EXPECT_NE(last_active_browser_to_restore, panel_browser); | |
344 } | |
345 #endif | |
346 | |
347 if (params.show_flag == SHOW_AS_ACTIVE) { | 333 if (params.show_flag == SHOW_AS_ACTIVE) { |
348 panel->Show(); | 334 panel->Show(); |
349 } else { | 335 } else { |
350 panel->ShowInactive(); | 336 panel->ShowInactive(); |
351 } | 337 } |
352 | 338 |
353 if (params.wait_for_fully_created) { | 339 if (params.wait_for_fully_created) { |
354 MessageLoopForUI::current()->RunAllPending(); | 340 MessageLoopForUI::current()->RunAllPending(); |
355 | 341 |
356 #if defined(OS_LINUX) | 342 #if defined(OS_LINUX) |
357 // Restore focus where it was. It will deactivate the new panel. | 343 // On bots, we might have a simple window manager which always activates new |
358 if (last_active_browser_to_restore) | 344 // windows, and can't always deactivate them. Re-activate the main tabbed |
359 last_active_browser_to_restore->window()->Activate(); | 345 // browser to "deactivate" the newly created panel. |
| 346 if (params.expected_active_state == SHOW_AS_INACTIVE && |
| 347 ui::GuessWindowManager() == ui::WM_ICE_WM) { |
| 348 browser()->window()->Activate(); |
| 349 } |
360 #endif | 350 #endif |
361 // More waiting, because gaining or losing focus may require inter-process | 351 // More waiting, because gaining or losing focus may require inter-process |
362 // asynchronous communication, and it is not enough to just run the local | 352 // asynchronous communication, and it is not enough to just run the local |
363 // message loop to make sure this activity has completed. | 353 // message loop to make sure this activity has completed. |
364 WaitForPanelActiveState(panel, params.expected_active_state); | 354 WaitForPanelActiveState(panel, params.expected_active_state); |
365 | 355 |
366 // On Linux, window size is not available right away and we should wait | 356 // On Linux, window size is not available right away and we should wait |
367 // before moving forward with the test. | 357 // before moving forward with the test. |
368 WaitForWindowSizeAvailable(panel); | 358 WaitForWindowSizeAvailable(panel); |
369 | 359 |
370 // Wait for the bounds animations on creation to finish. | 360 // Wait for the bounds animations on creation to finish. |
371 WaitForBoundsAnimationFinished(panel); | 361 WaitForBoundsAnimationFinished(panel); |
372 } | 362 } |
373 | 363 |
374 return panel; | 364 return panel; |
375 } | 365 } |
376 | 366 |
377 Panel* BasePanelBrowserTest::CreatePanelWithBounds( | 367 Panel* OldBasePanelBrowserTest::CreatePanelWithBounds( |
378 const std::string& panel_name, const gfx::Rect& bounds) { | 368 const std::string& panel_name, const gfx::Rect& bounds) { |
379 CreatePanelParams params(panel_name, bounds, SHOW_AS_ACTIVE); | 369 CreatePanelParams params(panel_name, bounds, SHOW_AS_ACTIVE); |
380 return CreatePanelWithParams(params); | 370 return CreatePanelWithParams(params); |
381 } | 371 } |
382 | 372 |
383 Panel* BasePanelBrowserTest::CreatePanel(const std::string& panel_name) { | 373 Panel* OldBasePanelBrowserTest::CreatePanel(const std::string& panel_name) { |
384 CreatePanelParams params(panel_name, gfx::Rect(), SHOW_AS_ACTIVE); | 374 CreatePanelParams params(panel_name, gfx::Rect(), SHOW_AS_ACTIVE); |
385 return CreatePanelWithParams(params); | 375 return CreatePanelWithParams(params); |
386 } | 376 } |
387 | 377 |
388 Panel* BasePanelBrowserTest::CreateDockedPanel(const std::string& name, | 378 Panel* OldBasePanelBrowserTest::CreateDockedPanel(const std::string& name, |
389 const gfx::Rect& bounds) { | 379 const gfx::Rect& bounds) { |
390 Panel* panel = CreatePanelWithBounds(name, bounds); | 380 Panel* panel = CreatePanelWithBounds(name, bounds); |
391 EXPECT_EQ(PanelStrip::DOCKED, panel->panel_strip()->type()); | 381 EXPECT_EQ(PanelStrip::DOCKED, panel->panel_strip()->type()); |
392 return panel; | 382 return panel; |
393 } | 383 } |
394 | 384 |
395 Panel* BasePanelBrowserTest::CreateDetachedPanel(const std::string& name, | 385 Panel* OldBasePanelBrowserTest::CreateDetachedPanel(const std::string& name, |
396 const gfx::Rect& bounds) { | 386 const gfx::Rect& bounds) { |
397 Panel* panel = CreatePanelWithBounds(name, bounds); | 387 Panel* panel = CreatePanelWithBounds(name, bounds); |
398 panel->manager()->MovePanelToStrip(panel, | 388 panel->manager()->MovePanelToStrip(panel, |
399 PanelStrip::DETACHED, | 389 PanelStrip::DETACHED, |
400 PanelStrip::DEFAULT_POSITION); | 390 PanelStrip::DEFAULT_POSITION); |
401 EXPECT_EQ(PanelStrip::DETACHED, panel->panel_strip()->type()); | 391 EXPECT_EQ(PanelStrip::DETACHED, panel->panel_strip()->type()); |
402 // The panel is first created as docked panel, which ignores the specified | 392 // The panel is first created as docked panel, which ignores the specified |
403 // origin in |bounds|. We need to reposition the panel after it becomes | 393 // origin in |bounds|. We need to reposition the panel after it becomes |
404 // detached. | 394 // detached. |
405 panel->SetPanelBounds(bounds); | 395 panel->SetPanelBounds(bounds); |
406 WaitForBoundsAnimationFinished(panel); | 396 WaitForBoundsAnimationFinished(panel); |
407 return panel; | 397 return panel; |
408 } | 398 } |
409 | 399 |
410 void BasePanelBrowserTest::CreateTestTabContents(Browser* browser) { | 400 void OldBasePanelBrowserTest::CreateTestTabContents(Browser* browser) { |
411 TabContentsWrapper* tab_contents = | 401 TabContentsWrapper* tab_contents = |
412 new TabContentsWrapper( | 402 new TabContentsWrapper( |
413 WebContentsTester::CreateTestWebContents(browser->profile(), NULL)); | 403 WebContentsTester::CreateTestWebContents(browser->profile(), NULL)); |
414 browser->AddTab(tab_contents, content::PAGE_TRANSITION_LINK); | 404 browser->AddTab(tab_contents, content::PAGE_TRANSITION_LINK); |
415 } | 405 } |
416 | 406 |
417 scoped_refptr<Extension> BasePanelBrowserTest::CreateExtension( | 407 scoped_refptr<Extension> OldBasePanelBrowserTest::CreateExtension( |
418 const FilePath::StringType& path, | 408 const FilePath::StringType& path, |
419 Extension::Location location, | 409 Extension::Location location, |
420 const DictionaryValue& extra_value) { | 410 const DictionaryValue& extra_value) { |
421 #if defined(OS_WIN) | 411 #if defined(OS_WIN) |
422 FilePath full_path(FILE_PATH_LITERAL("c:\\")); | 412 FilePath full_path(FILE_PATH_LITERAL("c:\\")); |
423 #else | 413 #else |
424 FilePath full_path(FILE_PATH_LITERAL("/")); | 414 FilePath full_path(FILE_PATH_LITERAL("/")); |
425 #endif | 415 #endif |
426 full_path = full_path.Append(path); | 416 full_path = full_path.Append(path); |
427 | 417 |
428 scoped_ptr<DictionaryValue> input_value(extra_value.DeepCopy()); | 418 scoped_ptr<DictionaryValue> input_value(extra_value.DeepCopy()); |
429 input_value->SetString(extension_manifest_keys::kVersion, "1.0.0.0"); | 419 input_value->SetString(extension_manifest_keys::kVersion, "1.0.0.0"); |
430 input_value->SetString(extension_manifest_keys::kName, "Sample Extension"); | 420 input_value->SetString(extension_manifest_keys::kName, "Sample Extension"); |
431 | 421 |
432 std::string error; | 422 std::string error; |
433 scoped_refptr<Extension> extension = Extension::Create( | 423 scoped_refptr<Extension> extension = Extension::Create( |
434 full_path, location, *input_value, Extension::NO_FLAGS, &error); | 424 full_path, location, *input_value, Extension::NO_FLAGS, &error); |
435 EXPECT_TRUE(extension.get()); | 425 EXPECT_TRUE(extension.get()); |
436 EXPECT_STREQ("", error.c_str()); | 426 EXPECT_STREQ("", error.c_str()); |
437 browser()->profile()->GetExtensionService()-> | 427 browser()->profile()->GetExtensionService()-> |
438 OnExtensionInstalled(extension.get(), false, StringOrdinal()); | 428 OnExtensionInstalled(extension.get(), false, StringOrdinal()); |
439 return extension; | 429 return extension; |
440 } | 430 } |
441 | 431 |
442 void BasePanelBrowserTest::SetTestingAreas(const gfx::Rect& primary_screen_area, | 432 void OldBasePanelBrowserTest::SetTestingAreas( |
443 const gfx::Rect& work_area) { | 433 const gfx::Rect& primary_screen_area, |
| 434 const gfx::Rect& work_area) { |
444 DCHECK(primary_screen_area.Contains(work_area)); | 435 DCHECK(primary_screen_area.Contains(work_area)); |
445 mock_display_settings_provider_->SetPrimaryScreenArea(primary_screen_area); | 436 mock_display_settings_provider_->SetPrimaryScreenArea(primary_screen_area); |
446 mock_display_settings_provider_->SetWorkArea( | 437 mock_display_settings_provider_->SetWorkArea( |
447 work_area.IsEmpty() ? primary_screen_area : work_area); | 438 work_area.IsEmpty() ? primary_screen_area : work_area); |
448 } | 439 } |
449 | 440 |
450 void BasePanelBrowserTest::CloseWindowAndWait(Panel* panel) { | 441 void OldBasePanelBrowserTest::CloseWindowAndWait(Panel* panel) { |
451 // Closing a panel may involve several async tasks. Need to use | 442 // Closing a panel may involve several async tasks. Need to use |
452 // message pump and wait for the notification. | 443 // message pump and wait for the notification. |
453 PanelManager* manager = PanelManager::GetInstance(); | 444 PanelManager* manager = PanelManager::GetInstance(); |
454 int panel_count = manager->num_panels(); | 445 int panel_count = manager->num_panels(); |
455 ui_test_utils::WindowedNotificationObserver signal( | 446 ui_test_utils::WindowedNotificationObserver signal( |
456 chrome::NOTIFICATION_PANEL_CLOSED, | 447 chrome::NOTIFICATION_PANEL_CLOSED, |
457 content::Source<Panel>(panel)); | 448 content::Source<Panel>(panel)); |
458 panel->Close(); | 449 panel->Close(); |
459 signal.Wait(); | 450 signal.Wait(); |
460 // Now we have one less panel. | 451 // Now we have one less panel. |
461 EXPECT_EQ(panel_count - 1, manager->num_panels()); | 452 EXPECT_EQ(panel_count - 1, manager->num_panels()); |
462 | 453 |
463 #if defined(OS_MACOSX) | 454 #if defined(OS_MACOSX) |
464 // Mac window controllers may be autoreleased, and in the non-test | 455 // Mac window controllers may be autoreleased, and in the non-test |
465 // environment, may actually depend on the autorelease pool being recycled | 456 // environment, may actually depend on the autorelease pool being recycled |
466 // with the run loop in order to perform important work. Replicate this in | 457 // with the run loop in order to perform important work. Replicate this in |
467 // the test environment. | 458 // the test environment. |
468 AutoreleasePool()->Recycle(); | 459 AutoreleasePool()->Recycle(); |
469 | 460 |
470 // Make sure that everything has a chance to run. | 461 // Make sure that everything has a chance to run. |
471 chrome::testing::NSRunLoopRunAllPending(); | 462 chrome::testing::NSRunLoopRunAllPending(); |
472 #endif // OS_MACOSX | 463 #endif // OS_MACOSX |
473 } | 464 } |
474 | 465 |
475 void BasePanelBrowserTest::MoveMouseAndWaitForExpansionStateChange( | 466 void OldBasePanelBrowserTest::MoveMouseAndWaitForExpansionStateChange( |
476 Panel* panel, | 467 Panel* panel, |
477 const gfx::Point& position) { | 468 const gfx::Point& position) { |
478 ui_test_utils::WindowedNotificationObserver signal( | 469 ui_test_utils::WindowedNotificationObserver signal( |
479 chrome::NOTIFICATION_PANEL_CHANGED_EXPANSION_STATE, | 470 chrome::NOTIFICATION_PANEL_CHANGED_EXPANSION_STATE, |
480 content::Source<Panel>(panel)); | 471 content::Source<Panel>(panel)); |
481 MoveMouse(position); | 472 MoveMouse(position); |
482 signal.Wait(); | 473 signal.Wait(); |
483 } | 474 } |
484 | 475 |
485 void BasePanelBrowserTest::MoveMouse(const gfx::Point& position) { | 476 void OldBasePanelBrowserTest::MoveMouse(const gfx::Point& position) { |
486 PanelManager::GetInstance()->mouse_watcher()->NotifyMouseMovement(position); | 477 PanelManager::GetInstance()->mouse_watcher()->NotifyMouseMovement(position); |
487 } | 478 } |
488 | 479 |
489 std::string BasePanelBrowserTest::MakePanelName(int index) { | 480 std::string OldBasePanelBrowserTest::MakePanelName(int index) { |
490 std::string panel_name("Panel"); | 481 std::string panel_name("Panel"); |
491 return panel_name + base::IntToString(index); | 482 return panel_name + base::IntToString(index); |
492 } | 483 } |
OLD | NEW |