forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
24hour clock now using current active user's settings
BUG=386949 TEST=SystemTrayDelegateChromeOSTest.TestMultiProfile24HourClock Review URL: https://codereview.chromium.org/784903002 Cr-Commit-Position: refs/heads/master@{#309186}
- Loading branch information
rsorokin
authored and
Commit bot
committed
Dec 19, 2014
1 parent
33cad73
commit c957804
Showing
5 changed files
with
122 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
chrome/browser/ui/ash/system_tray_delegate_chromeos_browsertest_chromeos.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// Copyright 2014 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "chrome/browser/ui/ash/system_tray_delegate_chromeos.h" | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
#include "ash/shell.h" | ||
#include "ash/system/date/date_default_view.h" | ||
#include "ash/system/date/date_view.h" | ||
#include "ash/system/date/tray_date.h" | ||
#include "base/prefs/pref_service.h" | ||
#include "chrome/browser/chromeos/login/login_manager_test.h" | ||
#include "chrome/browser/chromeos/login/session/user_session_manager.h" | ||
#include "chrome/browser/chromeos/login/startup_utils.h" | ||
#include "chrome/browser/chromeos/login/ui/user_adding_screen.h" | ||
#include "chrome/browser/chromeos/profiles/profile_helper.h" | ||
#include "chrome/common/pref_names.h" | ||
#include "components/user_manager/user_manager.h" | ||
#include "content/public/test/test_utils.h" | ||
|
||
namespace chromeos { | ||
|
||
namespace { | ||
|
||
const char* kUser1 = "user1@test.com"; | ||
const char* kUser2 = "user2@test.com"; | ||
|
||
base::HourClockType GetHourType() { | ||
const ash::TrayDate* tray_date = ash::Shell::GetInstance() | ||
->GetPrimarySystemTray() | ||
->GetTrayDateForTesting(); | ||
const ash::DateDefaultView* date_default_view = | ||
tray_date->GetDefaultViewForTesting(); | ||
|
||
return date_default_view->GetDateView()->GetHourTypeForTesting(); | ||
} | ||
|
||
void CreateDefaultView() { | ||
ash::TrayDate* tray_date = ash::Shell::GetInstance() | ||
->GetPrimarySystemTray() | ||
->GetTrayDateForTesting(); | ||
tray_date->CreateDefaultViewForTesting(ash::user::LOGGED_IN_NONE); | ||
} | ||
|
||
} // namespace | ||
|
||
class SystemTrayDelegateChromeOSTest : public LoginManagerTest { | ||
protected: | ||
SystemTrayDelegateChromeOSTest() | ||
: LoginManagerTest(false /* should_launch_browser */) {} | ||
|
||
virtual ~SystemTrayDelegateChromeOSTest() {} | ||
|
||
void SetupUserProfile(std::string user_name, bool use_24_hour_clock) { | ||
const user_manager::User* user = | ||
user_manager::UserManager::Get()->FindUser(user_name); | ||
Profile* profile = ProfileHelper::Get()->GetProfileByUser(user); | ||
profile->GetPrefs()->SetBoolean(prefs::kUse24HourClock, use_24_hour_clock); | ||
} | ||
|
||
private: | ||
DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegateChromeOSTest); | ||
}; | ||
|
||
IN_PROC_BROWSER_TEST_F(SystemTrayDelegateChromeOSTest, | ||
PRE_TestMultiProfile24HourClock) { | ||
RegisterUser(kUser1); | ||
RegisterUser(kUser2); | ||
StartupUtils::MarkOobeCompleted(); | ||
} | ||
|
||
// Test that clock type is taken from user profile for current active user. | ||
IN_PROC_BROWSER_TEST_F(SystemTrayDelegateChromeOSTest, | ||
TestMultiProfile24HourClock) { | ||
LoginUser(kUser1); | ||
SetupUserProfile(kUser1, true /* use_24_hour_clock */); | ||
CreateDefaultView(); | ||
EXPECT_EQ(base::k24HourClock, GetHourType()); | ||
UserAddingScreen::Get()->Start(); | ||
content::RunAllPendingInMessageLoop(); | ||
AddUser(kUser2); | ||
SetupUserProfile(kUser2, false /* use_24_hour_clock */); | ||
CreateDefaultView(); | ||
EXPECT_EQ(base::k12HourClock, GetHourType()); | ||
user_manager::UserManager::Get()->SwitchActiveUser(kUser1); | ||
CreateDefaultView(); | ||
EXPECT_EQ(base::k24HourClock, GetHourType()); | ||
} | ||
|
||
} // namespace chromeos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters