#include "chrome/browser/ui/views/frame/webui_tab_strip_field_trial.h"
#include <string_view>
#include <vector>
#include "base/command_line.h"
#include "base/memory/scoped_refptr.h"
#include "base/metrics/field_trial.h"
#include "base/ranges/algorithm.h"
#include "base/test/mock_entropy_provider.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "components/variations/active_field_trials.h"
#include "components/variations/synthetic_trials_active_group_id_provider.h"
#include "content/public/test/browser_test.h"
#include "testing/gtest/include/gtest/gtest.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "ash/constants/ash_switches.h"
#endif
namespace {
void RegisterFakeFieldTrialWithState(base::FeatureList* feature_list,
bool enabled) { … }
bool IsInGroup(std::string_view group_name) { … }
}
class WebUITabStripFieldTrialBrowserTest : public InProcessBrowserTest { … };
class WebUITabStripFieldTrialDefaultTabletModeBrowserTest
: public WebUITabStripFieldTrialBrowserTest { … };
IN_PROC_BROWSER_TEST_F(WebUITabStripFieldTrialDefaultTabletModeBrowserTest,
GroupDependsOnTabletMode) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
class WebUITabStripFieldTrialWithTabletModeBrowserTest
: public WebUITabStripFieldTrialBrowserTest {
public:
WebUITabStripFieldTrialWithTabletModeBrowserTest() {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
ash::switches::kAshEnableTabletMode);
}
};
class WebUITabStripFieldTrialEnabledBrowserTest
: public WebUITabStripFieldTrialWithTabletModeBrowserTest {
public:
WebUITabStripFieldTrialEnabledBrowserTest() {
RegisterFakeFieldTrialWithState(feature_list(), true);
InitFeatureList();
EXPECT_TRUE(base::FeatureList::IsEnabled(features::kWebUITabStrip));
}
};
IN_PROC_BROWSER_TEST_F(WebUITabStripFieldTrialEnabledBrowserTest, Test) {
EXPECT_TRUE(IsInGroup("Enabled"));
EXPECT_FALSE(IsInGroup("Disabled"));
EXPECT_FALSE(IsInGroup("Default"));
}
class WebUITabStripFieldTrialDisabledBrowserTest
: public WebUITabStripFieldTrialWithTabletModeBrowserTest {
public:
WebUITabStripFieldTrialDisabledBrowserTest() {
RegisterFakeFieldTrialWithState(feature_list(), false);
InitFeatureList();
EXPECT_FALSE(base::FeatureList::IsEnabled(features::kWebUITabStrip));
}
};
IN_PROC_BROWSER_TEST_F(WebUITabStripFieldTrialDisabledBrowserTest, Test) {
EXPECT_FALSE(IsInGroup("Enabled"));
EXPECT_TRUE(IsInGroup("Disabled"));
EXPECT_FALSE(IsInGroup("Default"));
}
class WebUITabStripFieldTrialCommandLineOverrideBrowserTest
: public WebUITabStripFieldTrialWithTabletModeBrowserTest {
public:
WebUITabStripFieldTrialCommandLineOverrideBrowserTest() {
feature_list()->InitFromCommandLine("WebUITabStrip", "");
InitFeatureList();
EXPECT_TRUE(base::FeatureList::IsEnabled(features::kWebUITabStrip));
}
};
IN_PROC_BROWSER_TEST_F(WebUITabStripFieldTrialCommandLineOverrideBrowserTest,
Test) {
EXPECT_FALSE(IsInGroup("Enabled"));
EXPECT_FALSE(IsInGroup("Disabled"));
EXPECT_FALSE(IsInGroup("Default"));
}
#endif