Commit e0f19547 authored by Andre Le's avatar Andre Le Committed by Commit Bot

Ash Status Tray: fix tests to enable ManagedDeviceUIRedesign feature

BUG=921267

Change-Id: I6bbb3723975666cf2b488eda8a34d69e80384f80
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2308229
Commit-Queue: Andre Le <leandre@chromium.org>
Reviewed-by: default avatarTim Song <tengs@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#791009}
parent 4d8b34ef
......@@ -36,6 +36,7 @@ enum ViewID {
VIEW_ID_STICKY_HEADER,
// System tray menu item for "device is managed by example.com".
VIEW_ID_TRAY_ENTERPRISE,
VIEW_ID_TRAY_ENTERPRISE_LABEL,
// System tray up-arrow icon that shows an update is available.
VIEW_ID_TRAY_UPDATE_ICON,
// System tray menu item label for updates (e.g. "Restart to update").
......
......@@ -58,6 +58,10 @@ class ASH_EXPORT SystemTrayTestApi {
// does not exist.
base::string16 GetBubbleViewTooltip(int view_id);
// Returns the text for a bubble view, or the empty string if the view
// does not exist. This method only works if the bubble view is a label.
base::string16 GetBubbleViewText(int view_id);
// Get the notification pop up view based on the notification id.
message_center::MessagePopupView* GetPopupViewForNotificationID(
const std::string& notification_id);
......
......@@ -97,6 +97,11 @@ base::string16 SystemTrayTestApi::GetBubbleViewTooltip(int view_id) {
return view ? view->GetTooltipText(gfx::Point()) : base::string16();
}
base::string16 SystemTrayTestApi::GetBubbleViewText(int view_id) {
views::View* view = GetBubbleView(view_id);
return view ? static_cast<views::Label*>(view)->GetText() : base::string16();
}
bool SystemTrayTestApi::Is24HourClock() {
base::HourClockType type =
GetTray()->time_view_->time_view()->GetHourTypeForTesting();
......
......@@ -47,6 +47,7 @@ UnifiedManagedDeviceView::UnifiedManagedDeviceView(
label_->SetEnabledColor(AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kTextColorSecondary,
AshColorProvider::AshColorMode::kDark));
label_->SetID(VIEW_ID_TRAY_ENTERPRISE_LABEL);
AddChildView(label_);
SetID(VIEW_ID_TRAY_ENTERPRISE);
......
......@@ -24,13 +24,14 @@ class UnifiedSystemInfoViewTest : public AshTestBase {
void SetUp() override {
AshTestBase::SetUp();
model_ = std::make_unique<UnifiedSystemTrayModel>(nullptr);
controller_ = std::make_unique<UnifiedSystemTrayController>(model_.get());
info_view_ = std::make_unique<UnifiedSystemInfoView>(controller_.get());
scoped_feature_list_ = std::make_unique<base::test::ScopedFeatureList>();
scoped_feature_list_->InitAndDisableFeature(
features::kManagedDeviceUIRedesign);
model_ = std::make_unique<UnifiedSystemTrayModel>(nullptr);
controller_ = std::make_unique<UnifiedSystemTrayController>(model_.get());
info_view_ = std::make_unique<UnifiedSystemInfoView>(controller_.get());
}
void TearDown() override {
......@@ -83,6 +84,8 @@ TEST_F(UnifiedSystemInfoViewTest, EnterpriseManagedVisibleForActiveDirectory) {
using UnifiedSystemInfoViewNoSessionTest = NoSessionAshTestBase;
TEST_F(UnifiedSystemInfoViewNoSessionTest, SupervisedVisible) {
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndDisableFeature(features::kManagedDeviceUIRedesign);
std::unique_ptr<UnifiedSystemTrayModel> model_ =
std::make_unique<UnifiedSystemTrayModel>(nullptr);
std::unique_ptr<UnifiedSystemTrayController> controller_ =
......
......@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/ash_view_ids.h"
#include "ash/public/cpp/login_screen.h"
#include "ash/public/cpp/login_screen_model.h"
......@@ -224,9 +225,16 @@ IN_PROC_BROWSER_TEST_F(LoginScreenButtonsLocalePolicy, UnifiedTrayLabelsText) {
EXPECT_TRUE(unified_tray_test_api->IsBubbleViewVisible(
ash::VIEW_ID_TRAY_ENTERPRISE, true /* open_tray */));
// Actual text on EnterpriseManagedView tooltip.
base::string16 actual_text =
unified_tray_test_api->GetBubbleViewTooltip(ash::VIEW_ID_TRAY_ENTERPRISE);
base::string16 actual_text;
if (ash::features::IsManagedDeviceUIRedesignEnabled()) {
// Actual text on UnifiedManagedDeviceView text.
actual_text = unified_tray_test_api->GetBubbleViewText(
ash::VIEW_ID_TRAY_ENTERPRISE_LABEL);
} else {
// Actual text on EnterpriseManagedView tooltip.
actual_text = unified_tray_test_api->GetBubbleViewTooltip(
ash::VIEW_ID_TRAY_ENTERPRISE);
}
// Text on EnterpriseManagedView tooltip in current locale.
base::string16 expected_text = l10n_util::GetStringFUTF16(
......
......@@ -4,6 +4,7 @@
#include "chrome/browser/ui/ash/system_tray_client.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/ash_view_ids.h"
#include "ash/public/cpp/login_screen_test_api.h"
#include "ash/public/cpp/system_tray_test_api.h"
......@@ -40,10 +41,17 @@ IN_PROC_BROWSER_TEST_F(SystemTrayClientEnterpriseTest, TrayEnterprise) {
EXPECT_TRUE(test_api->IsBubbleViewVisible(ash::VIEW_ID_TRAY_ENTERPRISE,
true /* open_tray */));
// The tooltip shows the domain.
EXPECT_EQ(l10n_util::GetStringFUTF16(IDS_ASH_ENTERPRISE_DEVICE_MANAGED_BY,
base::UTF8ToUTF16("example.com")),
test_api->GetBubbleViewTooltip(ash::VIEW_ID_TRAY_ENTERPRISE));
if (ash::features::IsManagedDeviceUIRedesignEnabled()) {
// The text shows the domain.
EXPECT_EQ(l10n_util::GetStringFUTF16(IDS_ASH_ENTERPRISE_DEVICE_MANAGED_BY,
base::UTF8ToUTF16("example.com")),
test_api->GetBubbleViewText(ash::VIEW_ID_TRAY_ENTERPRISE_LABEL));
} else {
// The tooltip shows the domain.
EXPECT_EQ(l10n_util::GetStringFUTF16(IDS_ASH_ENTERPRISE_DEVICE_MANAGED_BY,
base::UTF8ToUTF16("example.com")),
test_api->GetBubbleViewTooltip(ash::VIEW_ID_TRAY_ENTERPRISE));
}
// Clicking the item opens the management page.
test_api->ClickBubbleView(ash::VIEW_ID_TRAY_ENTERPRISE);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment