| 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 <string.h> | 7 #include <string.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" |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 // On a Mac, it transforms background-only test process into foreground one. | 275 // On a Mac, it transforms background-only test process into foreground one. |
| 276 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 276 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| 277 } | 277 } |
| 278 | 278 |
| 279 void BasePanelBrowserTest::WaitForPanelActiveState( | 279 void BasePanelBrowserTest::WaitForPanelActiveState( |
| 280 Panel* panel, ActiveState expected_state) { | 280 Panel* panel, ActiveState expected_state) { |
| 281 DCHECK(expected_state == SHOW_AS_ACTIVE || | 281 DCHECK(expected_state == SHOW_AS_ACTIVE || |
| 282 expected_state == SHOW_AS_INACTIVE); | 282 expected_state == SHOW_AS_INACTIVE); |
| 283 | 283 |
| 284 #if defined(OS_MACOSX) | 284 #if defined(OS_MACOSX) |
| 285 scoped_ptr<NativePanelTesting> panel_testing( | 285 std::unique_ptr<NativePanelTesting> panel_testing( |
| 286 CreateNativePanelTesting(panel)); | 286 CreateNativePanelTesting(panel)); |
| 287 ASSERT_TRUE(panel_testing->EnsureApplicationRunOnForeground()) << | 287 ASSERT_TRUE(panel_testing->EnsureApplicationRunOnForeground()) << |
| 288 "Failed to bring application to foreground. Bail out."; | 288 "Failed to bring application to foreground. Bail out."; |
| 289 #endif | 289 #endif |
| 290 | 290 |
| 291 PanelActiveStateObserver signal(panel, expected_state == SHOW_AS_ACTIVE); | 291 PanelActiveStateObserver signal(panel, expected_state == SHOW_AS_ACTIVE); |
| 292 signal.Wait(); | 292 signal.Wait(); |
| 293 } | 293 } |
| 294 | 294 |
| 295 void BasePanelBrowserTest::WaitForBoundsAnimationFinished(Panel* panel) { | 295 void BasePanelBrowserTest::WaitForBoundsAnimationFinished(Panel* panel) { |
| 296 scoped_ptr<NativePanelTesting> panel_testing( | 296 std::unique_ptr<NativePanelTesting> panel_testing( |
| 297 CreateNativePanelTesting(panel)); | 297 CreateNativePanelTesting(panel)); |
| 298 // Sometimes there are several animations in sequence due to content | 298 // Sometimes there are several animations in sequence due to content |
| 299 // auto resizing. Wait for all animations to finish. | 299 // auto resizing. Wait for all animations to finish. |
| 300 while (panel_testing->IsAnimatingBounds()) { | 300 while (panel_testing->IsAnimatingBounds()) { |
| 301 content::WindowedNotificationObserver signal( | 301 content::WindowedNotificationObserver signal( |
| 302 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, | 302 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, |
| 303 content::Source<Panel>(panel)); | 303 content::Source<Panel>(panel)); |
| 304 if (!panel_testing->IsAnimatingBounds()) | 304 if (!panel_testing->IsAnimatingBounds()) |
| 305 return; | 305 return; |
| 306 signal.Wait(); | 306 signal.Wait(); |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 } | 517 } |
| 518 | 518 |
| 519 scoped_refptr<Extension> BasePanelBrowserTest::CreateExtension( | 519 scoped_refptr<Extension> BasePanelBrowserTest::CreateExtension( |
| 520 const base::FilePath::StringType& path, | 520 const base::FilePath::StringType& path, |
| 521 extensions::Manifest::Location location, | 521 extensions::Manifest::Location location, |
| 522 const base::DictionaryValue& extra_value) { | 522 const base::DictionaryValue& extra_value) { |
| 523 extensions::ExtensionPrefs* extension_prefs = | 523 extensions::ExtensionPrefs* extension_prefs = |
| 524 extensions::ExtensionPrefs::Get(browser()->profile()); | 524 extensions::ExtensionPrefs::Get(browser()->profile()); |
| 525 base::FilePath full_path = extension_prefs->install_directory().Append(path); | 525 base::FilePath full_path = extension_prefs->install_directory().Append(path); |
| 526 | 526 |
| 527 scoped_ptr<base::DictionaryValue> input_value(extra_value.DeepCopy()); | 527 std::unique_ptr<base::DictionaryValue> input_value(extra_value.DeepCopy()); |
| 528 input_value->SetString(extensions::manifest_keys::kVersion, "1.0.0.0"); | 528 input_value->SetString(extensions::manifest_keys::kVersion, "1.0.0.0"); |
| 529 input_value->SetString(extensions::manifest_keys::kName, "Sample Extension"); | 529 input_value->SetString(extensions::manifest_keys::kName, "Sample Extension"); |
| 530 | 530 |
| 531 std::string error; | 531 std::string error; |
| 532 scoped_refptr<Extension> extension = Extension::Create( | 532 scoped_refptr<Extension> extension = Extension::Create( |
| 533 full_path, location, *input_value, Extension::NO_FLAGS, &error); | 533 full_path, location, *input_value, Extension::NO_FLAGS, &error); |
| 534 EXPECT_TRUE(extension.get()); | 534 EXPECT_TRUE(extension.get()); |
| 535 EXPECT_STREQ("", error.c_str()); | 535 EXPECT_STREQ("", error.c_str()); |
| 536 extensions::ExtensionSystem::Get( | 536 extensions::ExtensionSystem::Get( |
| 537 browser()->profile())->extension_service()->OnExtensionInstalled( | 537 browser()->profile())->extension_service()->OnExtensionInstalled( |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 } | 581 } |
| 582 | 582 |
| 583 std::string BasePanelBrowserTest::MakePanelName(int index) { | 583 std::string BasePanelBrowserTest::MakePanelName(int index) { |
| 584 std::string panel_name("Panel"); | 584 std::string panel_name("Panel"); |
| 585 return panel_name + base::IntToString(index); | 585 return panel_name + base::IntToString(index); |
| 586 } | 586 } |
| 587 | 587 |
| 588 bool BasePanelBrowserTest::WmSupportWindowActivation() { | 588 bool BasePanelBrowserTest::WmSupportWindowActivation() { |
| 589 return true; | 589 return true; |
| 590 } | 590 } |
| OLD | NEW |