#include "chrome/browser/compose/compose_enabling.h"
#include <vector>
#include "base/feature_list.h"
#include "base/test/gmock_expected_support.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/about_flags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/compose/chrome_compose_client.h"
#include "chrome/browser/optimization_guide/browser_test_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/compose/core/browser/compose_features.h"
#include "components/optimization_guide/core/model_execution/model_execution_features.h"
#include "components/optimization_guide/core/optimization_guide_features.h"
#include "components/optimization_guide/core/optimization_guide_prefs.h"
#include "components/prefs/pref_service.h"
#include "components/signin/public/identity_manager/identity_test_utils.h"
#include "components/unified_consent/pref_names.h"
#include "components/variations/service/variations_service.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/fenced_frame_test_util.h"
#include "content/public/test/test_host_resolver.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/default_handlers.h"
#include "testing/gtest/include/gtest/gtest.h"
#if BUILDFLAG(IS_CHROMEOS)
#include "chromeos/constants/chromeos_features.h"
#endif
class ComposeEnablingBrowserTestBase : public InProcessBrowserTest { … };
class ComposeEnablingBrowserTest : public ComposeEnablingBrowserTestBase { … };
IN_PROC_BROWSER_TEST_F(ComposeEnablingBrowserTest,
PRE_EnableComposeViaSettings) { … }
IN_PROC_BROWSER_TEST_F(ComposeEnablingBrowserTest, EnableComposeViaSettings) { … }
class GraduatedComposeEnablingBrowserTest
: public ComposeEnablingBrowserTestBase { … };
IN_PROC_BROWSER_TEST_F(GraduatedComposeEnablingBrowserTest, GraduatedCompose) { … }
#if BUILDFLAG(IS_CHROMEOS)
class ComposeOnChromeOS : public ComposeEnablingBrowserTestBase {
public:
ComposeOnChromeOS() {
scoped_feature_list_.InitWithFeatures(
{
optimization_guide::features::kOptimizationGuideModelExecution,
optimization_guide::features::internal::kComposeSettingsVisibility,
#if BUILDFLAG(IS_CHROMEOS)
chromeos::features::kFeatureManagementDisableChromeCompose,
#endif
},
{
optimization_guide::features::internal::kComposeGraduated,
chromeos::features::kOrca,
chromeos::features::kOrcaDogfood,
});
}
};
IN_PROC_BROWSER_TEST_F(ComposeOnChromeOS,
PRE_ComposeDisabledOnNonEligibleCrOSDevices) {
EnableComposePreReqs();
EXPECT_EQ(base::unexpected(compose::ComposeShowStatus::kDisabledOnChromeOS),
GetComposeEnabling().IsEnabled());
}
IN_PROC_BROWSER_TEST_F(ComposeOnChromeOS,
ComposeDisabledOnNonEligibleCrOSDevices) {
EXPECT_EQ(base::unexpected(compose::ComposeShowStatus::kDisabledOnChromeOS),
GetComposeEnabling().IsEnabled());
}
class GraduatedComposeOnChromeOS : public ComposeEnablingBrowserTestBase {
public:
GraduatedComposeOnChromeOS() {
scoped_feature_list_.InitWithFeatures(
{
optimization_guide::features::kOptimizationGuideModelExecution,
optimization_guide::features::internal::kComposeGraduated,
#if BUILDFLAG(IS_CHROMEOS)
chromeos::features::kFeatureManagementDisableChromeCompose,
#endif
},
{
optimization_guide::features::internal::kComposeSettingsVisibility,
chromeos::features::kOrca,
chromeos::features::kOrcaDogfood,
});
}
};
IN_PROC_BROWSER_TEST_F(GraduatedComposeOnChromeOS,
GraduatedComposeDisabledOnNonEligibleCrOSDevices) {
EnableComposePreReqs();
EXPECT_EQ(base::unexpected(compose::ComposeShowStatus::kDisabledOnChromeOS),
GetComposeEnabling().IsEnabled());
}
#endif
class ComposeEnablingWithFencedFramesBrowserTest
: public ComposeEnablingBrowserTest { … };
IN_PROC_BROWSER_TEST_F(ComposeEnablingWithFencedFramesBrowserTest,
DisabledInFencedFrames) { … }