Commit 04c4b1b3 authored by Christopher Cameron's avatar Christopher Cameron Committed by Commit Bot

MacPWAs: Enable multi-profile by default

This is now in a good enough shape to turn on. The remaining work is to
add tracking to ensure that we open the most-recently-used profile on
launch.

Bug: 982024
Change-Id: Ib6b922a1ebca043a6c8f8eb2ded2cd3c837cc80d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1902866
Commit-Queue: ccameron <ccameron@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713659}
parent 98234211
......@@ -314,13 +314,15 @@ class TestHost : public AppShimHost {
DISALLOW_COPY_AND_ASSIGN(TestHost);
};
class ExtensionAppShimHandlerTest : public testing::Test {
class ExtensionAppShimHandlerTestBase : public testing::Test {
protected:
ExtensionAppShimHandlerTest()
: delegate_(new MockDelegate),
handler_(new TestingExtensionAppShimHandler(delegate_)),
profile_path_a_("Profile A"),
profile_path_b_("Profile B") {
ExtensionAppShimHandlerTestBase() {}
void SetUp() override {
delegate_ = new MockDelegate;
handler_.reset(new TestingExtensionAppShimHandler(delegate_));
profile_path_a_ = base::FilePath("Profile A");
profile_path_b_ = base::FilePath("Profile B");
AppShimHostBootstrap::SetClient(handler_.get());
bootstrap_aa_ = (new TestingAppShimHostBootstrap(
profile_path_a_, kTestAppIdA,
......@@ -421,7 +423,7 @@ class ExtensionAppShimHandlerTest : public testing::Test {
.WillRepeatedly(Return());
}
~ExtensionAppShimHandlerTest() override {
~ExtensionAppShimHandlerTestBase() override {
host_aa_unique_.reset();
host_ab_unique_.reset();
host_bb_unique_.reset();
......@@ -529,7 +531,34 @@ class ExtensionAppShimHandlerTest : public testing::Test {
scoped_refptr<const Extension> extension_b_;
private:
DISALLOW_COPY_AND_ASSIGN(ExtensionAppShimHandlerTest);
DISALLOW_COPY_AND_ASSIGN(ExtensionAppShimHandlerTestBase);
};
class ExtensionAppShimHandlerTest : public ExtensionAppShimHandlerTestBase {
public:
void SetUp() override {
scoped_features_.InitWithFeatures(
/*enabled_features=*/{},
/*disabled_features=*/{features::kAppShimMultiProfile});
ExtensionAppShimHandlerTestBase::SetUp();
}
private:
base::test::ScopedFeatureList scoped_features_;
};
class ExtensionAppShimHandlerTestMultiProfile
: public ExtensionAppShimHandlerTestBase {
public:
void SetUp() override {
scoped_features_.InitWithFeatures(
/*enabled_features=*/{features::kAppShimMultiProfile},
/*disabled_features=*/{});
ExtensionAppShimHandlerTestBase::SetUp();
}
private:
base::test::ScopedFeatureList scoped_features_;
};
TEST_F(ExtensionAppShimHandlerTest, LaunchProfileNotFound) {
......@@ -866,12 +895,7 @@ TEST_F(ExtensionAppShimHandlerTest, PreExistingHost) {
EXPECT_EQ(host_aa_.get(), handler_->FindHost(&profile_a_, kTestAppIdA));
}
TEST_F(ExtensionAppShimHandlerTest, MultiProfile) {
base::test::ScopedFeatureList scoped_features;
scoped_features.InitWithFeatures(
/*enabled_features=*/{features::kAppShimMultiProfile},
/*disabled_features=*/{});
TEST_F(ExtensionAppShimHandlerTestMultiProfile, MultiProfile) {
// Test with a bookmark app (host is shared).
{
// Create a host for profile A.
......@@ -907,12 +931,7 @@ TEST_F(ExtensionAppShimHandlerTest, MultiProfile) {
}
}
TEST_F(ExtensionAppShimHandlerTest, MultiProfileShimLaunch) {
base::test::ScopedFeatureList scoped_features;
scoped_features.InitWithFeatures(
/*enabled_features=*/{features::kAppShimMultiProfile},
/*disabled_features=*/{});
TEST_F(ExtensionAppShimHandlerTestMultiProfile, MultiProfileShimLaunch) {
delegate_->SetHostForCreate(std::move(host_aa_unique_));
ShimLaunchedCallback launched_callback;
delegate_->SetCaptureShimLaunchedCallback(&launched_callback);
......@@ -939,12 +958,7 @@ TEST_F(ExtensionAppShimHandlerTest, MultiProfileShimLaunch) {
EXPECT_TRUE(terminated_callback);
}
TEST_F(ExtensionAppShimHandlerTest, MultiProfileSelectMenu) {
base::test::ScopedFeatureList scoped_features;
scoped_features.InitWithFeatures(
/*enabled_features=*/{features::kAppShimMultiProfile},
/*disabled_features=*/{});
TEST_F(ExtensionAppShimHandlerTestMultiProfile, MultiProfileSelectMenu) {
delegate_->SetHostForCreate(std::move(host_aa_unique_));
ShimLaunchedCallback launched_callback;
delegate_->SetCaptureShimLaunchedCallback(&launched_callback);
......@@ -980,12 +994,7 @@ TEST_F(ExtensionAppShimHandlerTest, MultiProfileSelectMenu) {
host_aa_->ProfileSelectedFromMenu(profile_path_b_);
}
TEST_F(ExtensionAppShimHandlerTest, ProfileMenuOneProfile) {
base::test::ScopedFeatureList scoped_features;
scoped_features.InitWithFeatures(
/*enabled_features=*/{features::kAppShimMultiProfile},
/*disabled_features=*/{});
TEST_F(ExtensionAppShimHandlerTestMultiProfile, ProfileMenuOneProfile) {
// Set this app to be installed for profile A.
{
auto item_a = chrome::mojom::ProfileMenuItem::New();
......@@ -1048,12 +1057,7 @@ TEST_F(ExtensionAppShimHandlerTest, ProfileMenuOneProfile) {
EXPECT_FALSE(delegate_->RunGetProfilesForAppCallback());
}
TEST_F(ExtensionAppShimHandlerTest, FindProfileFromBadProfile) {
base::test::ScopedFeatureList scoped_features;
scoped_features.InitWithFeatures(
/*enabled_features=*/{features::kAppShimMultiProfile},
/*disabled_features=*/{});
TEST_F(ExtensionAppShimHandlerTestMultiProfile, FindProfileFromBadProfile) {
// Set this app to be installed for profile A.
{
auto item_a = chrome::mojom::ProfileMenuItem::New();
......@@ -1076,12 +1080,7 @@ TEST_F(ExtensionAppShimHandlerTest, FindProfileFromBadProfile) {
EXPECT_EQ(host_aa_.get(), handler_->FindHost(&profile_a_, kTestAppIdA));
}
TEST_F(ExtensionAppShimHandlerTest, FindProfileFromNoProfile) {
base::test::ScopedFeatureList scoped_features;
scoped_features.InitWithFeatures(
/*enabled_features=*/{features::kAppShimMultiProfile},
/*disabled_features=*/{});
TEST_F(ExtensionAppShimHandlerTestMultiProfile, FindProfileFromNoProfile) {
// Set this app to be installed for profile A.
{
auto item_a = chrome::mojom::ProfileMenuItem::New();
......
......@@ -20,6 +20,8 @@
#include "base/path_service.h"
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#import "chrome/common/mac/app_mode_common.h"
......@@ -348,6 +350,11 @@ TEST_F(WebAppShortcutCreatorTest, DeleteShortcuts) {
}
TEST_F(WebAppShortcutCreatorTest, DeleteAllShortcutsForProfile) {
base::test::ScopedFeatureList scoped_features;
scoped_features.InitWithFeatures(
/*enabled_features=*/{},
/*disabled_features=*/{features::kAppShimMultiProfile});
NiceMock<WebAppShortcutCreatorMock> shortcut_creator(app_data_dir_,
info_.get());
base::FilePath profile_path = info_->profile_path;
......
......@@ -37,7 +37,7 @@ const base::Feature kApkWebAppInstalls{"ApkWebAppInstalls",
// Enable the new multi-profile-aware app shim mode.
// TODO(https://crbug.com/982024): Delete this flag when feature is complete.
const base::Feature kAppShimMultiProfile{"AppShimMultiProfile",
base::FEATURE_DISABLED_BY_DEFAULT};
base::FEATURE_ENABLED_BY_DEFAULT};
// Can be used to disable RemoteCocoa (hosting NSWindows for apps in the app
// process). For debugging purposes only.
......
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