Commit 417b29c3 authored by Henrique Grandinetti's avatar Henrique Grandinetti Committed by Commit Bot

Update the parent access dialog title on timezone settings

Bug: 921145
Change-Id: I4bce60e976e9acaaff36597e2d50f87faefc0f39
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1678576
Commit-Queue: Henrique Grandinetti <hgrandinetti@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#672570}
parent e5c2c704
...@@ -112,6 +112,9 @@ base::string16 GetTitle(ParentAccessRequestReason reason) { ...@@ -112,6 +112,9 @@ base::string16 GetTitle(ParentAccessRequestReason reason) {
case ParentAccessRequestReason::kChangeTime: case ParentAccessRequestReason::kChangeTime:
title_id = IDS_ASH_LOGIN_PARENT_ACCESS_TITLE_CHANGE_TIME; title_id = IDS_ASH_LOGIN_PARENT_ACCESS_TITLE_CHANGE_TIME;
break; break;
case ParentAccessRequestReason::kChangeTimezone:
title_id = IDS_ASH_LOGIN_PARENT_ACCESS_TITLE_CHANGE_TIMEZONE;
break;
} }
return l10n_util::GetStringUTF16(title_id); return l10n_util::GetStringUTF16(title_id);
} }
...@@ -123,6 +126,7 @@ base::string16 GetDescription(ParentAccessRequestReason reason) { ...@@ -123,6 +126,7 @@ base::string16 GetDescription(ParentAccessRequestReason reason) {
description_id = IDS_ASH_LOGIN_PARENT_ACCESS_DESCRIPTION; description_id = IDS_ASH_LOGIN_PARENT_ACCESS_DESCRIPTION;
break; break;
case ParentAccessRequestReason::kChangeTime: case ParentAccessRequestReason::kChangeTime:
case ParentAccessRequestReason::kChangeTimezone:
description_id = IDS_ASH_LOGIN_PARENT_ACCESS_GENERIC_DESCRIPTION; description_id = IDS_ASH_LOGIN_PARENT_ACCESS_GENERIC_DESCRIPTION;
break; break;
} }
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "base/optional.h" #include "base/optional.h"
#include "base/test/bind_test_util.h" #include "base/test/bind_test_util.h"
#include "components/account_id/account_id.h" #include "components/account_id/account_id.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/events/base_event_utils.h" #include "ui/events/base_event_utils.h"
#include "ui/events/event.h" #include "ui/events/event.h"
...@@ -33,6 +34,27 @@ namespace ash { ...@@ -33,6 +34,27 @@ namespace ash {
namespace { namespace {
// Struct containing the correct title and description that are displayed when
// the dialog is instantiated with a given ParentAccessRequestReason.
struct ViewModifiersTestData {
ParentAccessRequestReason reason;
// The title string id.
int title;
// The description string id.
int description;
};
const ViewModifiersTestData kViewModifiersTestData[] = {
{ParentAccessRequestReason::kUnlockTimeLimits,
IDS_ASH_LOGIN_PARENT_ACCESS_TITLE,
IDS_ASH_LOGIN_PARENT_ACCESS_DESCRIPTION},
{ParentAccessRequestReason::kChangeTime,
IDS_ASH_LOGIN_PARENT_ACCESS_TITLE_CHANGE_TIME,
IDS_ASH_LOGIN_PARENT_ACCESS_GENERIC_DESCRIPTION},
{ParentAccessRequestReason::kChangeTimezone,
IDS_ASH_LOGIN_PARENT_ACCESS_TITLE_CHANGE_TIMEZONE,
IDS_ASH_LOGIN_PARENT_ACCESS_GENERIC_DESCRIPTION}};
class ParentAccessViewTest : public LoginTestBase { class ParentAccessViewTest : public LoginTestBase {
protected: protected:
ParentAccessViewTest() ParentAccessViewTest()
...@@ -89,31 +111,26 @@ class ParentAccessViewTest : public LoginTestBase { ...@@ -89,31 +111,26 @@ class ParentAccessViewTest : public LoginTestBase {
DISALLOW_COPY_AND_ASSIGN(ParentAccessViewTest); DISALLOW_COPY_AND_ASSIGN(ParentAccessViewTest);
}; };
class ParentAccessViewModifiersTest
: public ParentAccessViewTest,
public ::testing::WithParamInterface<ViewModifiersTestData> {};
} // namespace } // namespace
// Tests that title and description are correctly set when reason is unlock time // Tests that title and description are correctly set.
// limits. TEST_P(ParentAccessViewModifiersTest, CheckStrings) {
TEST_F(ParentAccessViewTest, UnlockTimeLimitsStrings) { const ViewModifiersTestData& test_data = GetParam();
StartView(ParentAccessRequestReason::kUnlockTimeLimits); StartView(test_data.reason);
ParentAccessView::TestApi test_api(view_); ParentAccessView::TestApi test_api(view_);
EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_LOGIN_PARENT_ACCESS_TITLE), EXPECT_EQ(l10n_util::GetStringUTF16(test_data.title),
test_api.title_label()->GetText()); test_api.title_label()->GetText());
EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_LOGIN_PARENT_ACCESS_DESCRIPTION), EXPECT_EQ(l10n_util::GetStringUTF16(test_data.description),
test_api.description_label()->GetText()); test_api.description_label()->GetText());
} }
// Tests that title and description are correctly set when reason is change INSTANTIATE_TEST_SUITE_P(,
// time. ParentAccessViewModifiersTest,
TEST_F(ParentAccessViewTest, ChangeTimeStrings) { testing::ValuesIn(kViewModifiersTestData));
StartView(ParentAccessRequestReason::kChangeTime);
ParentAccessView::TestApi test_api(view_);
EXPECT_EQ(
l10n_util::GetStringUTF16(IDS_ASH_LOGIN_PARENT_ACCESS_TITLE_CHANGE_TIME),
test_api.title_label()->GetText());
EXPECT_EQ(l10n_util::GetStringUTF16(
IDS_ASH_LOGIN_PARENT_ACCESS_GENERIC_DESCRIPTION),
test_api.description_label()->GetText());
}
// Tests that back button works. // Tests that back button works.
TEST_F(ParentAccessViewTest, BackButton) { TEST_F(ParentAccessViewTest, BackButton) {
......
...@@ -292,8 +292,10 @@ struct ASH_PUBLIC_EXPORT AuthDisabledData { ...@@ -292,8 +292,10 @@ struct ASH_PUBLIC_EXPORT AuthDisabledData {
enum class ParentAccessRequestReason { enum class ParentAccessRequestReason {
// Unlock a Chromebook that is locked due to a Time Limit policy. // Unlock a Chromebook that is locked due to a Time Limit policy.
kUnlockTimeLimits, kUnlockTimeLimits,
// Change time or timezone of the Chromebook. // Update values on the date time dialog.
kChangeTime, kChangeTime,
// Update values on the timezone settings page.
kChangeTimezone,
}; };
} // namespace ash } // namespace ash
......
...@@ -165,7 +165,7 @@ void DateTimeHandler::HandleShowParentAccessForTimeZone( ...@@ -165,7 +165,7 @@ void DateTimeHandler::HandleShowParentAccessForTimeZone(
user_manager::UserManager::Get()->GetActiveUser()->GetAccountId(), user_manager::UserManager::Get()->GetActiveUser()->GetAccountId(),
base::BindRepeating(&DateTimeHandler::OnParentAccessValidation, base::BindRepeating(&DateTimeHandler::OnParentAccessValidation,
weak_ptr_factory_.GetWeakPtr()), weak_ptr_factory_.GetWeakPtr()),
ash::ParentAccessRequestReason::kChangeTime); ash::ParentAccessRequestReason::kChangeTimezone);
} }
void DateTimeHandler::OnParentAccessValidation(bool success) { void DateTimeHandler::OnParentAccessValidation(bool success) {
......
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