|
21 | 21 | #include "chrome/browser/chromeos/settings/stub_install_attributes.h"
|
22 | 22 | #include "chrome/browser/google/google_brand_chromeos.h"
|
23 | 23 | #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
|
| 24 | +#include "chrome/common/chrome_switches.h" |
24 | 25 | #include "chromeos/chromeos_switches.h"
|
25 | 26 | #include "chromeos/system/fake_statistics_provider.h"
|
26 | 27 | #include "chromeos/system/statistics_provider.h"
|
| 28 | +#include "components/user_manager/user_names.h" |
27 | 29 | #include "content/public/test/test_utils.h"
|
28 | 30 | #include "google_apis/gaia/fake_gaia.h"
|
29 | 31 | #include "rlz/buildflags/buildflags.h"
|
@@ -235,13 +237,69 @@ IN_PROC_BROWSER_TEST_F(ChromeSessionManagerRlzTest, DeviceIsLocked) {
|
235 | 237 | }
|
236 | 238 |
|
237 | 239 | IN_PROC_BROWSER_TEST_F(ChromeSessionManagerRlzTest, DeviceIsUnlocked) {
|
238 |
| - // When the device is unlocked, the brand should be cleared after session |
239 |
| - // start. |
| 240 | + // When the device is unlocked, the brand should still stick after a |
| 241 | + // regular session start. |
240 | 242 | stub_install_attributes()->set_device_locked(false);
|
241 | 243 | StartUserSession();
|
242 |
| - EXPECT_EQ("", google_brand::chromeos::GetBrand()); |
| 244 | + EXPECT_EQ("TEST", google_brand::chromeos::GetBrand()); |
| 245 | +} |
| 246 | + |
| 247 | +class GuestSessionRlzTest : public InProcessBrowserTest, |
| 248 | + public ::testing::WithParamInterface<bool> { |
| 249 | + public: |
| 250 | + GuestSessionRlzTest() : is_locked_(GetParam()) {} |
| 251 | + |
| 252 | + protected: |
| 253 | + StubInstallAttributes* stub_install_attributes() { |
| 254 | + return scoped_stub_install_attributes_->Get(); |
| 255 | + } |
| 256 | + |
| 257 | + private: |
| 258 | + void SetUpInProcessBrowserTestFixture() override { |
| 259 | + // Set the default brand code to a known value. |
| 260 | + scoped_fake_statistics_provider_.reset( |
| 261 | + new system::ScopedFakeStatisticsProvider()); |
| 262 | + scoped_fake_statistics_provider_->SetMachineStatistic( |
| 263 | + system::kRlzBrandCodeKey, "TEST"); |
| 264 | + |
| 265 | + // Lock the device as needed for this test. |
| 266 | + scoped_stub_install_attributes_ = |
| 267 | + std::make_unique<ScopedStubInstallAttributes>( |
| 268 | + StubInstallAttributes::CreateUnset()); |
| 269 | + scoped_stub_install_attributes_->Get()->set_device_locked(is_locked_); |
| 270 | + |
| 271 | + InProcessBrowserTest::SetUpInProcessBrowserTestFixture(); |
| 272 | + } |
| 273 | + |
| 274 | + void SetUpCommandLine(base::CommandLine* command_line) override { |
| 275 | + command_line->AppendSwitch(chromeos::switches::kGuestSession); |
| 276 | + command_line->AppendSwitch(::switches::kIncognito); |
| 277 | + command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "hash"); |
| 278 | + command_line->AppendSwitchASCII( |
| 279 | + chromeos::switches::kLoginUser, |
| 280 | + user_manager::GuestAccountId().GetUserEmail()); |
| 281 | + } |
| 282 | + |
| 283 | + // Test instance parameters. |
| 284 | + const bool is_locked_; |
| 285 | + |
| 286 | + std::unique_ptr<system::ScopedFakeStatisticsProvider> |
| 287 | + scoped_fake_statistics_provider_; |
| 288 | + std::unique_ptr<ScopedStubInstallAttributes> scoped_stub_install_attributes_; |
| 289 | + |
| 290 | + DISALLOW_COPY_AND_ASSIGN(GuestSessionRlzTest); |
| 291 | +}; |
| 292 | + |
| 293 | +IN_PROC_BROWSER_TEST_P(GuestSessionRlzTest, DeviceIsLocked) { |
| 294 | + const char* const expected_brand = |
| 295 | + stub_install_attributes()->IsDeviceLocked() ? "TEST" : ""; |
| 296 | + EXPECT_EQ(expected_brand, google_brand::chromeos::GetBrand()); |
243 | 297 | }
|
244 | 298 |
|
| 299 | +INSTANTIATE_TEST_CASE_P(GuestSessionRlzTest, |
| 300 | + GuestSessionRlzTest, |
| 301 | + ::testing::Values(false, true)); |
| 302 | + |
245 | 303 | #endif // BUILDFLAG(ENABLE_RLZ)
|
246 | 304 |
|
247 | 305 | } // namespace chromeos
|
0 commit comments