1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355
|
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ash/file_manager/file_manager_browsertest_utils.h"
namespace file_manager {
namespace test {
TestCase::TestCase(const char* const name) : name(name) {
CHECK(name && *name) << "no test case name";
}
TestCase& TestCase::InGuestMode() {
options.guest_mode = IN_GUEST_MODE;
return *this;
}
TestCase& TestCase::InIncognito() {
options.guest_mode = IN_INCOGNITO;
return *this;
}
TestCase& TestCase::TabletMode() {
options.tablet_mode = true;
return *this;
}
TestCase& TestCase::SetLocale(const std::string& locale) {
options.locale = locale;
return *this;
}
TestCase& TestCase::SetCountry(const std::string& country) {
options.country = country;
return *this;
}
TestCase& TestCase::EnableGenericDocumentsProvider() {
options.arc = true;
options.generic_documents_provider = true;
return *this;
}
TestCase& TestCase::DisableGenericDocumentsProvider() {
options.generic_documents_provider = false;
return *this;
}
TestCase& TestCase::EnablePhotosDocumentsProvider() {
options.arc = true;
options.photos_documents_provider = true;
return *this;
}
TestCase& TestCase::DisablePhotosDocumentsProvider() {
options.photos_documents_provider = false;
return *this;
}
TestCase& TestCase::EnableArc() {
options.arc = true;
return *this;
}
TestCase& TestCase::Offline() {
options.offline = true;
return *this;
}
TestCase& TestCase::EnableConflictDialog() {
options.enable_conflict_dialog = true;
return *this;
}
TestCase& TestCase::DisableNativeSmb() {
options.native_smb = false;
return *this;
}
TestCase& TestCase::FakeFileSystemProvider() {
options.fake_file_system_provider = true;
return *this;
}
TestCase& TestCase::DontMountVolumes() {
options.mount_volumes = false;
return *this;
}
TestCase& TestCase::DontObserveFileTasks() {
options.observe_file_tasks = false;
return *this;
}
TestCase& TestCase::EnableSinglePartitionFormat() {
options.single_partition_format = true;
return *this;
}
TestCase& TestCase::EnableMaterializedViews() {
options.enable_materialized_views = true;
return *this;
}
// Show the startup browser. Some tests invoke the file picker dialog during
// the test. Requesting a file picker from a background page is forbidden by
// the apps platform, and it's a bug that these tests do so.
// FindRuntimeContext() in select_file_dialog_extension.cc will use the last
// active browser in this case, which requires a Browser to be present. See
// https://crbug.com/736930.
TestCase& TestCase::WithBrowser() {
options.browser = true;
return *this;
}
TestCase& TestCase::EnableDlp() {
options.enable_dlp_files_restriction = true;
return *this;
}
TestCase& TestCase::EnableFilesPolicyNewUX() {
options.enable_files_policy_new_ux = true;
return *this;
}
TestCase& TestCase::EnableDriveTrash() {
options.enable_drive_trash = true;
return *this;
}
TestCase& TestCase::EnableUploadOfficeToCloud() {
options.enable_upload_office_to_cloud = true;
return *this;
}
TestCase& TestCase::EnableArcVm() {
options.enable_arc_vm = true;
return *this;
}
TestCase& TestCase::EnableMirrorSync() {
options.enable_mirrorsync = true;
return *this;
}
TestCase& TestCase::EnableFileTransferConnector() {
options.enable_file_transfer_connector = true;
return *this;
}
TestCase& TestCase::EnableFileTransferConnectorNewUX() {
options.enable_file_transfer_connector_new_ux = true;
return *this;
}
TestCase& TestCase::FileTransferConnectorReportOnlyMode() {
options.file_transfer_connector_report_only = true;
return *this;
}
TestCase& TestCase::BypassRequiresJustification() {
options.bypass_requires_justification = true;
return *this;
}
TestCase& TestCase::EnableLocalImageSearch() {
options.enable_local_image_search = true;
return *this;
}
TestCase& TestCase::DisableGoogleOneOfferFilesBanner() {
options.enable_google_one_offer_files_banner = false;
return *this;
}
TestCase& TestCase::DisableGoogleOneOfferFilesBannerWithG1Nudge() {
options.disable_google_one_offer_files_banner = true;
return *this;
}
TestCase& TestCase::FeatureIds(const std::vector<std::string>& ids) {
options.feature_ids = ids;
return *this;
}
TestCase& TestCase::EnableBulkPinning() {
options.enable_drive_bulk_pinning = true;
return *this;
}
TestCase& TestCase::EnableDriveShortcuts() {
options.enable_drive_shortcuts = true;
return *this;
}
TestCase& TestCase::SetDeviceMode(DeviceMode device_mode) {
options.device_mode = device_mode;
return *this;
}
TestCase& TestCase::SetTestAccountType(TestAccountType test_account_type) {
options.test_account_type = test_account_type;
return *this;
}
TestCase& TestCase::EnableCrosComponents() {
options.enable_cros_components = true;
return *this;
}
TestCase& TestCase::EnableSkyVault() {
options.enable_skyvault = true;
return *this;
}
std::string TestCase::GetFullName() const {
std::string full_name = name;
if (options.guest_mode == IN_GUEST_MODE) {
full_name += "_GuestMode";
}
if (options.guest_mode == IN_INCOGNITO) {
full_name += "_Incognito";
}
if (options.tablet_mode) {
full_name += "_TabletMode";
}
if (!options.locale.empty()) {
// You cannot use `-` in a test case name.
std::string locale_for_name;
base::ReplaceChars(options.locale, "-", "_", &locale_for_name);
full_name += "_" + locale_for_name;
}
if (!options.country.empty()) {
full_name += "_" + options.country;
}
if (options.offline) {
full_name += "_Offline";
}
if (options.enable_conflict_dialog) {
full_name += "_ConflictDialog";
}
if (!options.native_smb) {
full_name += "_DisableNativeSmb";
}
if (options.generic_documents_provider) {
full_name += "_GenericDocumentsProvider";
}
if (options.photos_documents_provider) {
full_name += "_PhotosDocumentsProvider";
}
if (options.single_partition_format) {
full_name += "_SinglePartitionFormat";
}
if (options.enable_drive_trash) {
full_name += "_DriveTrash";
}
if (options.enable_mirrorsync) {
full_name += "_MirrorSync";
}
if (options.file_transfer_connector_report_only) {
full_name += "_ReportOnly";
}
if (options.enable_local_image_search) {
full_name += "_LocalImageSearch";
}
// Google One offer is enabled by default. Append it to a test name only if
// it's different from the default value.
// TODO(b/315829911): Remove Google One offer files banner flag.
if (!options.enable_google_one_offer_files_banner) {
full_name += "_DisableGoogleOneOfferFilesBanner";
}
// Google One offer is disabled by default. Append it to a test name only if
// it's different from the default value.
// TODO(b/315829911): Remove Google One offer files banner flag.
if (options.disable_google_one_offer_files_banner) {
full_name += "_DisableGoogleOneOfferFilesBannerWithNudge";
}
if (options.enable_drive_bulk_pinning) {
full_name += "_DriveBulkPinning";
}
if (options.enable_drive_shortcuts) {
full_name += "_DriveShortcuts";
}
if (options.enable_cros_components) {
full_name += "_CrosComponents";
}
if (options.enable_materialized_views) {
full_name += "_MaterializedViews";
}
switch (options.device_mode) {
case kDeviceModeNotSet:
break;
case kConsumerOwned:
full_name += "_DeviceModeConsumerOwned";
break;
case kEnrolled:
full_name += "_DeviceModeEnrolled";
}
switch (options.test_account_type) {
case kTestAccountTypeNotSet:
break;
case kEnterprise:
full_name += "_AccountTypeEnterprise";
break;
case kChild:
full_name += "_AccountTypeChild";
break;
case kNonManaged:
full_name += "_AccountTypeNonManaged";
break;
case kNonManagedNonOwner:
full_name += "_AccountTypeNonManagedNonOwner";
break;
case kGoogler:
full_name += "_AccountTypeGoogler";
break;
}
return full_name;
}
std::ostream& operator<<(std::ostream& out, const TestCase& test_case) {
return out << test_case.options;
}
std::string PostTestCaseName(const ::testing::TestParamInfo<TestCase>& test) {
return test.param.GetFullName();
}
} // namespace test
} // namespace file_manager
|