Chromium Code Reviews| 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/base_panel_browser_test.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/json/json_file_value_serializer.h" | |
| 9 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 10 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 11 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 12 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
| 13 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/panels/native_panel.h" | 17 #include "chrome/browser/ui/panels/native_panel.h" |
| 17 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" | 18 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" |
| 18 #include "chrome/browser/ui/panels/panel_strip.h" | 19 #include "chrome/browser/ui/panels/panel_strip.h" |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 255 CreateNativePanelTesting(panel)); | 256 CreateNativePanelTesting(panel)); |
| 256 content::WindowedNotificationObserver signal( | 257 content::WindowedNotificationObserver signal( |
| 257 chrome::NOTIFICATION_PANEL_WINDOW_SIZE_KNOWN, | 258 chrome::NOTIFICATION_PANEL_WINDOW_SIZE_KNOWN, |
| 258 content::Source<Panel>(panel)); | 259 content::Source<Panel>(panel)); |
| 259 if (panel_testing->IsWindowSizeKnown()) | 260 if (panel_testing->IsWindowSizeKnown()) |
| 260 return; | 261 return; |
| 261 signal.Wait(); | 262 signal.Wait(); |
| 262 EXPECT_TRUE(panel_testing->IsWindowSizeKnown()); | 263 EXPECT_TRUE(panel_testing->IsWindowSizeKnown()); |
| 263 } | 264 } |
| 264 | 265 |
| 266 void BasePanelBrowserTest::WaitForAppIconAvailable(Panel* panel) { | |
| 267 content::WindowedNotificationObserver signal( | |
| 268 chrome::NOTIFICATION_PANEL_ICON_KNOWN, | |
| 269 content::Source<Panel>(panel)); | |
| 270 if (!panel->app_icon().IsEmpty()) | |
| 271 return; | |
| 272 signal.Wait(); | |
| 273 EXPECT_FALSE(panel->app_icon().IsEmpty()); | |
| 274 } | |
| 275 | |
| 265 void BasePanelBrowserTest::WaitForBoundsAnimationFinished(Panel* panel) { | 276 void BasePanelBrowserTest::WaitForBoundsAnimationFinished(Panel* panel) { |
| 266 scoped_ptr<NativePanelTesting> panel_testing( | 277 scoped_ptr<NativePanelTesting> panel_testing( |
| 267 CreateNativePanelTesting(panel)); | 278 CreateNativePanelTesting(panel)); |
| 268 // Sometimes there are several animations in sequence due to content | 279 // Sometimes there are several animations in sequence due to content |
| 269 // auto resizing. Wait for all animations to finish. | 280 // auto resizing. Wait for all animations to finish. |
| 270 while (panel_testing->IsAnimatingBounds()) { | 281 while (panel_testing->IsAnimatingBounds()) { |
| 271 content::WindowedNotificationObserver signal( | 282 content::WindowedNotificationObserver signal( |
| 272 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, | 283 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, |
| 273 content::Source<Panel>(panel)); | 284 content::Source<Panel>(panel)); |
| 274 if (!panel_testing->IsAnimatingBounds()) | 285 if (!panel_testing->IsAnimatingBounds()) |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 417 full_path, location, *input_value, Extension::NO_FLAGS, &error); | 428 full_path, location, *input_value, Extension::NO_FLAGS, &error); |
| 418 EXPECT_TRUE(extension.get()); | 429 EXPECT_TRUE(extension.get()); |
| 419 EXPECT_STREQ("", error.c_str()); | 430 EXPECT_STREQ("", error.c_str()); |
| 420 browser()->profile()->GetExtensionService()-> | 431 browser()->profile()->GetExtensionService()-> |
| 421 OnExtensionInstalled(extension.get(), false /* not from webstore */, | 432 OnExtensionInstalled(extension.get(), false /* not from webstore */, |
| 422 syncer::StringOrdinal(), | 433 syncer::StringOrdinal(), |
| 423 false /* no requirement errors */); | 434 false /* no requirement errors */); |
| 424 return extension; | 435 return extension; |
| 425 } | 436 } |
| 426 | 437 |
| 438 scoped_refptr<extensions::Extension> | |
| 439 BasePanelBrowserTest::LoadExtensionFromManifest( | |
|
jennb
2012/10/02 17:51:08
This logic makes assumptions about extension imple
jianli
2012/10/02 21:37:26
Moved it out to the new file and changed it to use
| |
| 440 const FilePath::StringType& manifest_file) { | |
| 441 FilePath manifest_path; | |
| 442 PathService::Get(chrome::DIR_TEST_DATA, &manifest_path); | |
| 443 manifest_path = manifest_path.Append(kTestDir); | |
| 444 manifest_path = manifest_path.Append(manifest_file); | |
| 445 | |
| 446 JSONFileValueSerializer serializer(manifest_path); | |
| 447 scoped_ptr<DictionaryValue> manifest( | |
| 448 static_cast<DictionaryValue*>(serializer.Deserialize(NULL, NULL))); | |
| 449 EXPECT_TRUE(manifest.get() != NULL); | |
| 450 | |
| 451 std::string error; | |
| 452 scoped_refptr<extensions::Extension> extension(Extension::Create( | |
| 453 manifest_path.DirName(), Extension::INVALID, *manifest.get(), | |
| 454 Extension::NO_FLAGS, &error)); | |
| 455 EXPECT_TRUE(extension.get()); | |
| 456 EXPECT_STREQ("", error.c_str()); | |
| 457 browser()->profile()->GetExtensionService()-> | |
| 458 OnExtensionInstalled(extension.get(), false /* not from webstore */, | |
| 459 syncer::StringOrdinal(), | |
| 460 false /* no requirement errors */); | |
| 461 return extension; | |
| 462 } | |
| 463 | |
| 427 void BasePanelBrowserTest::SetTestingAreas(const gfx::Rect& primary_screen_area, | 464 void BasePanelBrowserTest::SetTestingAreas(const gfx::Rect& primary_screen_area, |
| 428 const gfx::Rect& work_area) { | 465 const gfx::Rect& work_area) { |
| 429 DCHECK(primary_screen_area.Contains(work_area)); | 466 DCHECK(primary_screen_area.Contains(work_area)); |
| 430 mock_display_settings_provider_->SetPrimaryScreenArea(primary_screen_area); | 467 mock_display_settings_provider_->SetPrimaryScreenArea(primary_screen_area); |
| 431 mock_display_settings_provider_->SetWorkArea( | 468 mock_display_settings_provider_->SetWorkArea( |
| 432 work_area.IsEmpty() ? primary_screen_area : work_area); | 469 work_area.IsEmpty() ? primary_screen_area : work_area); |
| 433 } | 470 } |
| 434 | 471 |
| 435 void BasePanelBrowserTest::CloseWindowAndWait(Panel* panel) { | 472 void BasePanelBrowserTest::CloseWindowAndWait(Panel* panel) { |
| 436 // Closing a panel may involve several async tasks. Need to use | 473 // Closing a panel may involve several async tasks. Need to use |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 468 } | 505 } |
| 469 | 506 |
| 470 void BasePanelBrowserTest::MoveMouse(const gfx::Point& position) { | 507 void BasePanelBrowserTest::MoveMouse(const gfx::Point& position) { |
| 471 PanelManager::GetInstance()->mouse_watcher()->NotifyMouseMovement(position); | 508 PanelManager::GetInstance()->mouse_watcher()->NotifyMouseMovement(position); |
| 472 } | 509 } |
| 473 | 510 |
| 474 std::string BasePanelBrowserTest::MakePanelName(int index) { | 511 std::string BasePanelBrowserTest::MakePanelName(int index) { |
| 475 std::string panel_name("Panel"); | 512 std::string panel_name("Panel"); |
| 476 return panel_name + base::IntToString(index); | 513 return panel_name + base::IntToString(index); |
| 477 } | 514 } |
| OLD | NEW |