-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
InstalledLoader::ProfileCanUseNonComponentExtensions into its own file. Before this the method was coupled to InstalledLoader so any potential importing code would have to import it all. We are going to start using this method outside of InstalledLoader in a future CL so this does the decoupling for that. Bug: 1383740 Change-Id: I7089276ff8dbc37b5348d9931692637b7d7cc6fd Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4125478 Reviewed-by: David Bertoni <dbertoni@chromium.org> Commit-Queue: Justin Lulejian <jlulejian@chromium.org> Cr-Commit-Position: refs/heads/main@{#1100748}
- Loading branch information
Justin Lulejian
authored and
Chromium LUCI CQ
committed
Feb 3, 2023
1 parent
d9da963
commit d198df2
Showing
10 changed files
with
353 additions
and
430 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
chrome/browser/extensions/extension_service_user_test_base.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// 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/extensions/extension_service_user_test_base.h" | ||
#include "chrome/test/base/testing_profile.h" | ||
|
||
namespace extensions { | ||
|
||
ExtensionServiceUserTestBase::ExtensionServiceUserTestBase() = default; | ||
ExtensionServiceUserTestBase::~ExtensionServiceUserTestBase() = default; | ||
|
||
#if BUILDFLAG(IS_CHROMEOS_ASH) | ||
void ExtensionServiceUserTestBase::SetUp() { | ||
ExtensionServiceTestBase::SetUp(); | ||
scoped_user_manager_ = std::make_unique<user_manager::ScopedUserManager>( | ||
std::make_unique<ash::FakeChromeUserManager>()); | ||
account_id_ = | ||
AccountId::FromUserEmailGaiaId("test-user@testdomain.com", "1234567890"); | ||
} | ||
|
||
void ExtensionServiceUserTestBase::TearDown() { | ||
ExtensionServiceTestBase::TearDown(); | ||
profile_.reset(); | ||
scoped_user_manager_.reset(); | ||
} | ||
|
||
void ExtensionServiceUserTestBase::LoginChromeOSAshUser( | ||
const user_manager::User* user, | ||
const AccountId& account_id) { | ||
ASSERT_TRUE(user); | ||
GetFakeUserManager()->LoginUser(account_id, | ||
/*set_profile_created_flag=*/false); | ||
ASSERT_TRUE(GetFakeUserManager()->IsUserLoggedIn()); | ||
ASSERT_TRUE(user == GetFakeUserManager()->GetActiveUser()); | ||
} | ||
|
||
#endif // BUILDFLAG(IS_CHROMEOS_ASH) | ||
|
||
void ExtensionServiceUserTestBase::MaybeSetUpTestUser(bool is_guest) { | ||
profile_->SetGuestSession(is_guest); | ||
|
||
ASSERT_EQ(is_guest, profile_->IsGuestSession()); | ||
|
||
#if BUILDFLAG(IS_CHROMEOS_ASH) | ||
user_manager::User* user; | ||
AccountId account_id = account_id_; | ||
if (is_guest) { | ||
user = GetFakeUserManager()->AddGuestUser(); | ||
account_id = GetFakeUserManager()->GetGuestAccountId(); | ||
} else { | ||
user = GetFakeUserManager()->AddUser(account_id_); | ||
} | ||
ASSERT_NO_FATAL_FAILURE(LoginChromeOSAshUser(user, account_id)); | ||
#endif // BUILDFLAG(IS_CHROMEOS_ASH) | ||
} | ||
|
||
} // namespace extensions |
55 changes: 55 additions & 0 deletions
55
chrome/browser/extensions/extension_service_user_test_base.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// 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. | ||
|
||
#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_USER_TEST_BASE_H_ | ||
#define CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_USER_TEST_BASE_H_ | ||
|
||
#include "chrome/browser/extensions/extension_service_test_base.h" | ||
|
||
#if BUILDFLAG(IS_CHROMEOS_ASH) | ||
#include "chrome/browser/ash/login/users/fake_chrome_user_manager.h" | ||
#include "components/user_manager/scoped_user_manager.h" | ||
#endif | ||
|
||
namespace extensions { | ||
|
||
// Test class used to setup test users in the unit test for browser/lacros and | ||
// ChromeOS Ash. | ||
class ExtensionServiceUserTestBase : public ExtensionServiceTestBase { | ||
public: | ||
ExtensionServiceUserTestBase(); | ||
~ExtensionServiceUserTestBase() override; | ||
|
||
#if BUILDFLAG(IS_CHROMEOS_ASH) | ||
void SetUp() override; | ||
|
||
void TearDown() override; | ||
|
||
void LoginChromeOSAshUser(const user_manager::User* user, | ||
const AccountId& account_id); | ||
|
||
ash::FakeChromeUserManager* GetFakeUserManager() const { | ||
return static_cast<ash::FakeChromeUserManager*>( | ||
user_manager::UserManager::Get()); | ||
} | ||
#endif // BUILDFLAG(IS_CHROMEOS_ASH) | ||
|
||
// If browser/lacros: set the profile for the test as a guest if `is_guest` is | ||
// `true`. If ChromeOS Ash: do the above, but also login a | ||
// `user_manager::User` and set it to be a guest account if `is_guest` is | ||
// `true`. | ||
void MaybeSetUpTestUser(bool is_guest); | ||
|
||
#if BUILDFLAG(IS_CHROMEOS_ASH) | ||
protected: | ||
AccountId account_id_; | ||
|
||
private: | ||
std::unique_ptr<user_manager::ScopedUserManager> scoped_user_manager_; | ||
#endif // BUILDFLAG(IS_CHROMEOS_ASH) | ||
}; | ||
|
||
} // namespace extensions | ||
|
||
#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_USER_TEST_BASE_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.