Skip to content

Commit

Permalink
Share LogInTypeFor and AccountIdFor and fix typo in TestAccountType
Browse files Browse the repository at this point in the history
Share LogInTypeFor and AccountIdFor testing in
https://crrev.com/c/4230452.

Fix typo in TestAccountType: kNonManged -> kNonManaged.

Bug: None
Change-Id: I8bfc96699e2af50276153368ff8210dfb446a3f7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4270710
Reviewed-by: Luciano Pacheco <lucmult@chromium.org>
Commit-Queue: Cassy Chun-Crogan <cassycc@google.com>
Cr-Commit-Position: refs/heads/main@{#1107590}
  • Loading branch information
Cassy Chun-Crogan authored and Chromium LUCI CQ committed Feb 21, 2023
1 parent e2e344f commit b8ae26b
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 46 deletions.
51 changes: 6 additions & 45 deletions chrome/browser/ash/file_manager/file_manager_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ struct TestCase {
case kChild:
full_name += "_AccountTypeChild";
break;
case kNonManged:
case kNonManaged:
full_name += "_AccountTypeNonManaged";
break;
case kNonManagedNonOwner:
Expand Down Expand Up @@ -402,7 +402,7 @@ class LoggedInUserFilesAppBrowserTest : public FilesAppBrowserTest {
case kTestAccountTypeNotSet:
case kEnterprise:
case kChild:
case kNonManged:
case kNonManaged:
owner_email = logged_in_user_mixin_->GetAccountId().GetUserEmail();
break;
case kNonManagedNonOwner:
Expand Down Expand Up @@ -439,45 +439,6 @@ class LoggedInUserFilesAppBrowserTest : public FilesAppBrowserTest {
}
}

ash::LoggedInUserMixin::LogInType LogInTypeFor(
TestAccountType test_account_type) {
switch (test_account_type) {
case kTestAccountTypeNotSet:
CHECK(false) << "test_account_type option must be set for "
"LoggedInUserFilesAppBrowserTest";
// TODO(crbug.com/1061742): `base::ImmediateCrash` is necessary.
base::ImmediateCrash();
case kEnterprise:
return ash::LoggedInUserMixin::LogInType::kRegular;
case kChild:
return ash::LoggedInUserMixin::LogInType::kChild;
case kNonManged:
case kNonManagedNonOwner:
return ash::LoggedInUserMixin::LogInType::kRegular;
}
}

absl::optional<AccountId> AccountIdFor(TestAccountType test_account_type) {
switch (test_account_type) {
case kTestAccountTypeNotSet:
CHECK(false) << "test_account_type option must be set for "
"LoggedInUserFilesAppBrowserTest";
// `base::ImmediateCrash` is necessary for https://crbug.com/1061742.
base::ImmediateCrash();
case kEnterprise:
return AccountId::FromUserEmailGaiaId(
FakeGaiaMixin::kEnterpriseUser1,
FakeGaiaMixin::kEnterpriseUser1GaiaId);
case kChild:
// Use the default account provided by `LoggedInUserMixin`.
return absl::nullopt;
case kNonManged:
case kNonManagedNonOwner:
// Use the default account provided by `LoggedInUserMixin`.
return absl::nullopt;
}
}

std::unique_ptr<ash::LoggedInUserMixin> logged_in_user_mixin_;
std::unique_ptr<ash::DeviceStateMixin> device_state_mixin_;

Expand Down Expand Up @@ -1718,15 +1679,15 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P(
// `FilesAppBrowserTest`.
TestCase("driveGoogleOneOfferBannerEnabled")
.SetDeviceMode(DeviceMode::kConsumerOwned)
.SetTestAccountType(TestAccountType::kNonManged)
.SetTestAccountType(TestAccountType::kNonManaged)
.EnableGoogleOneOfferFilesBanner(),
// Google One offer banner is disabled by default.
TestCase("driveGoogleOneOfferBannerDisabled")
.SetDeviceMode(DeviceMode::kConsumerOwned)
.SetTestAccountType(TestAccountType::kNonManged),
.SetTestAccountType(TestAccountType::kNonManaged),
TestCase("driveGoogleOneOfferBannerDismiss")
.SetDeviceMode(DeviceMode::kConsumerOwned)
.SetTestAccountType(TestAccountType::kNonManged)
.SetTestAccountType(TestAccountType::kNonManaged)
.EnableGoogleOneOfferFilesBanner(),
TestCase("driveGoogleOneOfferBannerDisabled")
.EnableGoogleOneOfferFilesBanner()
Expand All @@ -1741,7 +1702,7 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P(
TestCase("driveGoogleOneOfferBannerDisabled")
.EnableGoogleOneOfferFilesBanner()
.SetDeviceMode(DeviceMode::kEnrolled)
.SetTestAccountType(TestAccountType::kNonManged),
.SetTestAccountType(TestAccountType::kNonManaged),
// We do not show a banner if a profile is not an owner profile.
TestCase("driveGoogleOneOfferBannerDisabled")
.EnableGoogleOneOfferFilesBanner()
Expand Down
39 changes: 39 additions & 0 deletions chrome/browser/ash/file_manager/file_manager_browsertest_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,45 @@ struct GetLocalPathMessage {

} // anonymous namespace

ash::LoggedInUserMixin::LogInType LogInTypeFor(
TestAccountType test_account_type) {
switch (test_account_type) {
case kTestAccountTypeNotSet:
CHECK(false) << "test_account_type option must be set for "
"LoggedInUserFilesAppBrowserTest";
// TODO(crbug.com/1061742): `base::ImmediateCrash` is necessary.
base::ImmediateCrash();
case kEnterprise:
return ash::LoggedInUserMixin::LogInType::kRegular;
case kChild:
return ash::LoggedInUserMixin::LogInType::kChild;
case kNonManaged:
case kNonManagedNonOwner:
return ash::LoggedInUserMixin::LogInType::kRegular;
}
}

absl::optional<AccountId> AccountIdFor(TestAccountType test_account_type) {
switch (test_account_type) {
case kTestAccountTypeNotSet:
CHECK(false) << "test_account_type option must be set for "
"LoggedInUserFilesAppBrowserTest";
// `base::ImmediateCrash` is necessary for https://crbug.com/1061742.
base::ImmediateCrash();
case kEnterprise:
return AccountId::FromUserEmailGaiaId(
FakeGaiaMixin::kEnterpriseUser1,
FakeGaiaMixin::kEnterpriseUser1GaiaId);
case kChild:
// Use the default account provided by `LoggedInUserMixin`.
return absl::nullopt;
case kNonManaged:
case kNonManagedNonOwner:
// Use the default account provided by `LoggedInUserMixin`.
return absl::nullopt;
}
}

std::ostream& operator<<(std::ostream& out, const GuestMode mode) {
switch (mode) {
case NOT_IN_GUEST_MODE:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/ash/crostini/fake_crostini_features.h"
#include "chrome/browser/ash/drive/drive_integration_service.h"
#include "chrome/browser/ash/login/test/logged_in_user_mixin.h"
#include "chrome/browser/extensions/mixin_based_extension_apitest.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/web_applications/web_app_id.h"
Expand Down Expand Up @@ -44,7 +45,7 @@ enum TestAccountType {
kTestAccountTypeNotSet,
kEnterprise,
kChild,
kNonManged,
kNonManaged,
// Non-managed account as a non owner profile on a device.
kNonManagedNonOwner,
};
Expand All @@ -62,6 +63,11 @@ class SmbfsTestVolume;
class HiddenTestVolume;
class GuestOsTestVolume;

ash::LoggedInUserMixin::LogInType LogInTypeFor(
TestAccountType test_account_type);

absl::optional<AccountId> AccountIdFor(TestAccountType test_account_type);

class FileManagerBrowserTestBase
: public content::DevToolsAgentHostObserver,
public extensions::MixinBasedExtensionApiTest {
Expand Down

0 comments on commit b8ae26b

Please sign in to comment.