summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/ash
diff options
context:
space:
mode:
authorskuhne@chromium.org <skuhne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-10 17:02:14 +0000
committerskuhne@chromium.org <skuhne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-10 17:02:14 +0000
commite0bd6c12d6709a8301d416950c4ef5518d55337a (patch)
treedf5ae308033e676e77ad1ff78b42bf4e076e80b3 /chrome/browser/ui/ash
parent740d029a927e258b35a547bc41fa5f4fd4d59141 (diff)
downloadchromium_src-e0bd6c12d6709a8301d416950c4ef5518d55337a.zip
chromium_src-e0bd6c12d6709a8301d416950c4ef5518d55337a.tar.gz
chromium_src-e0bd6c12d6709a8301d416950c4ef5518d55337a.tar.bz2
Fixing too long running unit tests on valgrind (produced by user switch animation)
BUG=361412 TEST=unittest Review URL: https://codereview.chromium.org/232133003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@263015 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/ash')
-rw-r--r--chrome/browser/ui/ash/launcher/chrome_launcher_controller_unittest.cc3
-rw-r--r--chrome/browser/ui/ash/multi_user/multi_user_notification_blocker_chromeos_unittest.cc3
-rw-r--r--chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc22
-rw-r--r--chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h17
-rw-r--r--chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos_unittest.cc21
-rw-r--r--chrome/browser/ui/ash/multi_user/user_switch_animator_chromeos.cc24
-rw-r--r--chrome/browser/ui/ash/multi_user/user_switch_animator_chromeos.h6
7 files changed, 63 insertions, 33 deletions
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_unittest.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_unittest.cc
index 208337a..7dd122d 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_unittest.cc
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_unittest.cc
@@ -880,7 +880,8 @@ class MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest
chrome::MultiUserWindowManagerChromeOS* manager =
static_cast<chrome::MultiUserWindowManagerChromeOS*>(
chrome::MultiUserWindowManager::GetInstance());
- manager->SetAnimationsForTest(true);
+ manager->SetAnimationSpeedForTest(
+ chrome::MultiUserWindowManagerChromeOS::ANIMATION_SPEED_DISABLED);
manager->ActiveUserChanged(name);
launcher_controller_->browser_status_monitor_for_test()->
ActiveUserChanged(name);
diff --git a/chrome/browser/ui/ash/multi_user/multi_user_notification_blocker_chromeos_unittest.cc b/chrome/browser/ui/ash/multi_user/multi_user_notification_blocker_chromeos_unittest.cc
index 14655777..1f73c3d 100644
--- a/chrome/browser/ui/ash/multi_user/multi_user_notification_blocker_chromeos_unittest.cc
+++ b/chrome/browser/ui/ash/multi_user/multi_user_notification_blocker_chromeos_unittest.cc
@@ -40,7 +40,8 @@ class MultiUserNotificationBlockerChromeOSTest
chrome::MultiUserWindowManager::CreateInstance();
// Disable any animations for the test.
- GetMultiUserWindowManager()->SetAnimationsForTest(true);
+ GetMultiUserWindowManager()->SetAnimationSpeedForTest(
+ chrome::MultiUserWindowManagerChromeOS::ANIMATION_SPEED_DISABLED);
GetMultiUserWindowManager()->notification_blocker_->AddObserver(this);
}
diff --git a/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc b/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc
index 6e6548a..a8a26cf 100644
--- a/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc
+++ b/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc
@@ -48,6 +48,10 @@ namespace {
// in / out.
const int kAnimationTimeMS = 100;
+// The animation time in milliseconds for the fade in and / or out when
+// switching users.
+const int kUserFadeTimeMS = 110;
+
// The animation time in ms for a window which get teleported to another screen.
const int kTeleportAnimationTimeMS = 300;
@@ -208,7 +212,7 @@ MultiUserWindowManagerChromeOS::MultiUserWindowManagerChromeOS(
notification_blocker_(new MultiUserNotificationBlockerChromeOS(
message_center::MessageCenter::Get(), this, current_user_id)),
suppress_visibility_changes_(false),
- animations_disabled_(false) {
+ animation_speed_(ANIMATION_SPEED_NORMAL) {
// Add a session state observer to be able to monitor session changes.
if (ash::Shell::HasInstance())
ash::Shell::GetInstance()->session_state_delegate()->
@@ -393,7 +397,8 @@ void MultiUserWindowManagerChromeOS::ActiveUserChanged(
current_user_id_ = user_id;
animation_.reset(
- new UserSwichAnimatorChromeOS(this, user_id, animations_disabled_));
+ new UserSwichAnimatorChromeOS(
+ this, user_id, GetAdjustedAnimationTimeInMS(kUserFadeTimeMS)));
}
void MultiUserWindowManagerChromeOS::OnWindowDestroyed(aura::Window* window) {
@@ -485,8 +490,9 @@ void MultiUserWindowManagerChromeOS::Observe(
AddBrowserWindow(content::Source<Browser>(source).ptr());
}
-void MultiUserWindowManagerChromeOS::SetAnimationsForTest(bool disable) {
- animations_disabled_ = disable;
+void MultiUserWindowManagerChromeOS::SetAnimationSpeedForTest(
+ MultiUserWindowManagerChromeOS::AnimationSpeed speed) {
+ animation_speed_ = speed;
}
bool MultiUserWindowManagerChromeOS::IsAnimationRunningForTest() {
@@ -682,7 +688,7 @@ void MultiUserWindowManagerChromeOS::SetWindowVisible(
int animation_time_in_ms) {
AnimationSetter animation_setter(
window,
- animations_disabled_ ? 0 : animation_time_in_ms);
+ GetAdjustedAnimationTimeInMS(animation_time_in_ms));
if (visible)
window->Show();
@@ -694,4 +700,10 @@ void MultiUserWindowManagerChromeOS::SetWindowVisible(
DCHECK_EQ(visible, window->IsVisible());
}
+int MultiUserWindowManagerChromeOS::GetAdjustedAnimationTimeInMS(
+ int default_time_in_ms) {
+ return animation_speed_ == ANIMATION_SPEED_NORMAL ? default_time_in_ms :
+ (animation_speed_ == ANIMATION_SPEED_FAST ? 10 : 0);
+}
+
} // namespace chrome
diff --git a/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h b/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h
index 1cc1a0c..66a89cc 100644
--- a/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h
+++ b/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h
@@ -61,6 +61,13 @@ class MultiUserWindowManagerChromeOS
public content::NotificationObserver,
public wm::TransientWindowObserver {
public:
+ // The speed which should be used to perform animations.
+ enum AnimationSpeed {
+ ANIMATION_SPEED_NORMAL, // The normal animation speed.
+ ANIMATION_SPEED_FAST, // Unit test speed which test animations.
+ ANIMATION_SPEED_DISABLED // Unit tests which do not require animations.
+ };
+
// Create the manager and use |active_user_id| as the active user.
explicit MultiUserWindowManagerChromeOS(const std::string& active_user_id);
virtual ~MultiUserWindowManagerChromeOS();
@@ -104,7 +111,7 @@ class MultiUserWindowManagerChromeOS
const content::NotificationDetails& details) OVERRIDE;
// Disable any animations for unit tests.
- void SetAnimationsForTest(bool disable);
+ void SetAnimationSpeedForTest(AnimationSpeed speed);
// Returns true when a user switch animation is running. For unit tests.
bool IsAnimationRunningForTest();
@@ -212,6 +219,10 @@ class MultiUserWindowManagerChromeOS
bool visible,
int aimation_time_in_ms);
+ // Get the animation time in milliseconds dependent on the |AnimationSpeed|
+ // from the passed |default_time_in_ms|.
+ int GetAdjustedAnimationTimeInMS(int default_time_in_ms);
+
// A lookup to see to which user the given window belongs to, where and if it
// should get shown.
WindowToEntryMap window_to_entry_;
@@ -244,8 +255,8 @@ class MultiUserWindowManagerChromeOS
// used is quite expensive.
static MultiProfileMode multi_user_mode_;
- // If true, all animations will be suppressed.
- bool animations_disabled_;
+ // The speed which is used to perform any animations.
+ AnimationSpeed animation_speed_;
// The animation between users.
scoped_ptr<UserSwichAnimatorChromeOS> animation_;
diff --git a/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos_unittest.cc b/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos_unittest.cc
index eccc981..44fe75c 100644
--- a/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos_unittest.cc
+++ b/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos_unittest.cc
@@ -157,7 +157,8 @@ void MultiUserWindowManagerChromeOSTest::SetUpForThisManyWindows(int windows) {
window_[i]->Show();
}
multi_user_window_manager_ = new chrome::MultiUserWindowManagerChromeOS("A");
- multi_user_window_manager_->SetAnimationsForTest(true);
+ multi_user_window_manager_->SetAnimationSpeedForTest(
+ chrome::MultiUserWindowManagerChromeOS::ANIMATION_SPEED_DISABLED);
chrome::MultiUserWindowManager::SetInstanceForTest(multi_user_window_manager_,
chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED);
EXPECT_TRUE(multi_user_window_manager_);
@@ -700,7 +701,8 @@ TEST_F(MultiUserWindowManagerChromeOSTest,
TEST_F(MultiUserWindowManagerChromeOSTest, FullUserSwitchAnimationTests) {
SetUpForThisManyWindows(3);
// Turn the use of delays and animation on.
- multi_user_window_manager()->SetAnimationsForTest(false);
+ multi_user_window_manager()->SetAnimationSpeedForTest(
+ chrome::MultiUserWindowManagerChromeOS::ANIMATION_SPEED_FAST);
// Set some owners and make sure we got what we asked for.
multi_user_window_manager()->SetWindowOwner(window(0), "A");
multi_user_window_manager()->SetWindowOwner(window(1), "B");
@@ -733,7 +735,8 @@ TEST_F(MultiUserWindowManagerChromeOSTest, FullUserSwitchAnimationTests) {
TEST_F(MultiUserWindowManagerChromeOSTest, SystemShutdownWithActiveAnimation) {
SetUpForThisManyWindows(2);
// Turn the use of delays and animation on.
- multi_user_window_manager()->SetAnimationsForTest(false);
+ multi_user_window_manager()->SetAnimationSpeedForTest(
+ chrome::MultiUserWindowManagerChromeOS::ANIMATION_SPEED_FAST);
// Set some owners and make sure we got what we asked for.
multi_user_window_manager()->SetWindowOwner(window(0), "A");
multi_user_window_manager()->SetWindowOwner(window(1), "B");
@@ -748,7 +751,8 @@ TEST_F(MultiUserWindowManagerChromeOSTest, SystemShutdownWithActiveAnimation) {
TEST_F(MultiUserWindowManagerChromeOSTest, AnimationSteps) {
SetUpForThisManyWindows(3);
// Turn the use of delays and animation on.
- multi_user_window_manager()->SetAnimationsForTest(false);
+ multi_user_window_manager()->SetAnimationSpeedForTest(
+ chrome::MultiUserWindowManagerChromeOS::ANIMATION_SPEED_FAST);
// Set some owners and make sure we got what we asked for.
multi_user_window_manager()->SetWindowOwner(window(0), "A");
multi_user_window_manager()->SetWindowOwner(window(1), "B");
@@ -811,7 +815,8 @@ TEST_F(MultiUserWindowManagerChromeOSTest, AnimationStepsScreenCoverage) {
TEST_F(MultiUserWindowManagerChromeOSTest, AnimationStepsMaximizeToNormal) {
SetUpForThisManyWindows(3);
// Turn the use of delays and animation on.
- multi_user_window_manager()->SetAnimationsForTest(false);
+ multi_user_window_manager()->SetAnimationSpeedForTest(
+ chrome::MultiUserWindowManagerChromeOS::ANIMATION_SPEED_FAST);
// Set some owners and make sure we got what we asked for.
multi_user_window_manager()->SetWindowOwner(window(0), "A");
wm::GetWindowState(window(0))->Maximize();
@@ -849,7 +854,8 @@ TEST_F(MultiUserWindowManagerChromeOSTest, AnimationStepsMaximizeToNormal) {
TEST_F(MultiUserWindowManagerChromeOSTest, AnimationStepsNormalToMaximized) {
SetUpForThisManyWindows(3);
// Turn the use of delays and animation on.
- multi_user_window_manager()->SetAnimationsForTest(false);
+ multi_user_window_manager()->SetAnimationSpeedForTest(
+ chrome::MultiUserWindowManagerChromeOS::ANIMATION_SPEED_FAST);
// Set some owners and make sure we got what we asked for.
multi_user_window_manager()->SetWindowOwner(window(0), "A");
multi_user_window_manager()->SetWindowOwner(window(1), "B");
@@ -888,7 +894,8 @@ TEST_F(MultiUserWindowManagerChromeOSTest, AnimationStepsNormalToMaximized) {
TEST_F(MultiUserWindowManagerChromeOSTest, AnimationStepsMaximizedToMaximized) {
SetUpForThisManyWindows(3);
// Turn the use of delays and animation on.
- multi_user_window_manager()->SetAnimationsForTest(false);
+ multi_user_window_manager()->SetAnimationSpeedForTest(
+ chrome::MultiUserWindowManagerChromeOS::ANIMATION_SPEED_FAST);
// Set some owners and make sure we got what we asked for.
multi_user_window_manager()->SetWindowOwner(window(0), "A");
wm::GetWindowState(window(0))->Maximize();
diff --git a/chrome/browser/ui/ash/multi_user/user_switch_animator_chromeos.cc b/chrome/browser/ui/ash/multi_user/user_switch_animator_chromeos.cc
index 53ebafa..42f8438 100644
--- a/chrome/browser/ui/ash/multi_user/user_switch_animator_chromeos.cc
+++ b/chrome/browser/ui/ash/multi_user/user_switch_animator_chromeos.cc
@@ -21,10 +21,6 @@ namespace chrome {
namespace {
-// The animation time in milliseconds for the fade in and / or out when
-// switching users.
-const int kUserFadeTimeMS = 110;
-
// The minimal possible animation time for animations which should happen
// "instantly".
const int kMinimalAnimationTimeMS = 1;
@@ -52,20 +48,20 @@ class UserChangeActionDisabler {
UserSwichAnimatorChromeOS::UserSwichAnimatorChromeOS(
MultiUserWindowManagerChromeOS* owner,
const std::string& new_user_id,
- bool animation_disabled)
+ int animation_speed_ms)
: owner_(owner),
new_user_id_(new_user_id),
- animation_disabled_(animation_disabled),
+ animation_speed_ms_(animation_speed_ms),
animation_step_(ANIMATION_STEP_HIDE_OLD_USER),
screen_cover_(GetScreenCover()) {
AdvanceUserTransitionAnimation();
- if (animation_disabled_) {
+ if (!animation_speed_ms_) {
FinalizeAnimation();
} else {
user_changed_animation_timer_.reset(new base::Timer(
FROM_HERE,
- base::TimeDelta::FromMilliseconds(kUserFadeTimeMS),
+ base::TimeDelta::FromMilliseconds(animation_speed_ms_),
base::Bind(
&UserSwichAnimatorChromeOS::AdvanceUserTransitionAnimation,
base::Unretained(this)),
@@ -135,9 +131,10 @@ void UserSwichAnimatorChromeOS::TransitionWallpaper(
if (animation_step == ANIMATION_STEP_HIDE_OLD_USER) {
// Set the wallpaper cross dissolve animation duration to our complete
// animation cycle for a fade in and fade out.
+ int duration =
+ NO_USER_COVERS_SCREEN == screen_cover_ ? (2 * animation_speed_ms_) : 0;
wallpaper_delegate->SetAnimationDurationOverride(
- NO_USER_COVERS_SCREEN == screen_cover_ ? (2 * kUserFadeTimeMS) :
- kMinimalAnimationTimeMS);
+ std::max(duration, kMinimalAnimationTimeMS));
if (screen_cover_ != NEW_USER_COVERS_SCREEN) {
chromeos::WallpaperManager::Get()->SetUserWallpaperNow(new_user_id_);
wallpaper_user_id_ =
@@ -160,7 +157,7 @@ void UserSwichAnimatorChromeOS::TransitionWallpaper(
void UserSwichAnimatorChromeOS::TransitionUserShelf(
AnimationStep animation_step) {
// The shelf animation duration override.
- int duration_override = kUserFadeTimeMS;
+ int duration_override = animation_speed_ms_;
// Handle the shelf order of items. This is done once the old user is hidden.
if (animation_step == ANIMATION_STEP_SHOW_NEW_USER) {
// Some unit tests have no ChromeLauncherController.
@@ -171,7 +168,7 @@ void UserSwichAnimatorChromeOS::TransitionUserShelf(
duration_override = 0;
}
- if (animation_disabled_ || animation_step == ANIMATION_STEP_FINALIZE)
+ if (!animation_speed_ms_ || animation_step == ANIMATION_STEP_FINALIZE)
return;
ash::Shell::RootWindowControllerList controller =
@@ -253,7 +250,8 @@ void UserSwichAnimatorChromeOS::TransitionWindows(
} else if (should_be_visible != is_visible) {
bool animate = true;
int duration = animation_step == ANIMATION_STEP_FINALIZE ?
- kMinimalAnimationTimeMS : (2 * kUserFadeTimeMS);
+ 0 : (2 * animation_speed_ms_);
+ duration = std::max(kMinimalAnimationTimeMS, duration);
if (animation_step != ANIMATION_STEP_FINALIZE &&
screen_cover_ == BOTH_USERS_COVER_SCREEN &&
CoversScreen(window)) {
diff --git a/chrome/browser/ui/ash/multi_user/user_switch_animator_chromeos.h b/chrome/browser/ui/ash/multi_user/user_switch_animator_chromeos.h
index a69fcb8..1ea4030 100644
--- a/chrome/browser/ui/ash/multi_user/user_switch_animator_chromeos.h
+++ b/chrome/browser/ui/ash/multi_user/user_switch_animator_chromeos.h
@@ -35,7 +35,7 @@ class UserSwichAnimatorChromeOS {
UserSwichAnimatorChromeOS(MultiUserWindowManagerChromeOS* owner,
const std::string& new_user_id,
- bool animation_disabled);
+ int animation_speed_ms);
~UserSwichAnimatorChromeOS();
// Check if a window is covering the entire work area of the screen it is on.
@@ -93,8 +93,8 @@ class UserSwichAnimatorChromeOS {
// The new user to set.
std::string new_user_id_;
- // If true, all animations will be suppressed.
- bool animation_disabled_;
+ // The animation speed in ms. If 0, animations are disabled.
+ int animation_speed_ms_;
// The next animation step for AdvanceUserTransitionAnimation().
AnimationStep animation_step_;