#include "chrome/browser/ui/views/toolbar/chrome_labs/chrome_labs_button.h"
#include "base/memory/raw_ptr.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/about_flags.h"
#include "chrome/browser/ui/browser_window/public/browser_window_features.h"
#include "chrome/browser/ui/toolbar/chrome_labs/chrome_labs_model.h"
#include "chrome/browser/ui/toolbar/chrome_labs/chrome_labs_prefs.h"
#include "chrome/browser/ui/toolbar/chrome_labs/chrome_labs_utils.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/test_with_browser_view.h"
#include "chrome/browser/ui/views/toolbar/chrome_labs/chrome_labs_bubble_view.h"
#include "chrome/browser/ui/views/toolbar/toolbar_view.h"
#include "chrome/browser/unexpire_flags.h"
#include "components/flags_ui/feature_entry_macros.h"
#include "ui/events/event_utils.h"
#include "ui/views/controls/dot_indicator.h"
#include "ui/views/test/button_test_api.h"
#include "ui/views/test/widget_test.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "ash/constants/ash_switches.h"
#include "base/command_line.h"
#include "base/memory/ptr_util.h"
#include "chrome/browser/ash/ownership/owner_settings_service_ash.h"
#include "chrome/browser/ash/ownership/owner_settings_service_ash_factory.h"
#include "chrome/common/pref_names.h"
#endif
#if BUILDFLAG(GOOGLE_CHROME_BRANDING) && !BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/test/base/scoped_channel_override.h"
#endif
#if !BUILDFLAG(IS_CHROMEOS_ASH) || !BUILDFLAG(GOOGLE_CHROME_BRANDING)
namespace {
const char kFirstTestFeatureId[] = …;
BASE_FEATURE(…);
const char kSecondTestFeatureId[] = …;
BASE_FEATURE(…);
const char kExpiredFlagTestFeatureId[] = …;
BASE_FEATURE(…);
}
class ChromeLabsButtonTest : public TestWithBrowserView { … };
TEST_F(ChromeLabsButtonTest, ShowAndHideChromeLabsBubbleOnPress) { … }
TEST_F(ChromeLabsButtonTest, ShouldButtonShowTest) { … }
TEST_F(ChromeLabsButtonTest, DotIndicatorTest) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
class ChromeLabsButtonTestSafeMode : public ChromeLabsButtonTest {
public:
ChromeLabsButtonTestSafeMode() : ChromeLabsButtonTest() {}
void SetUp() override {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
ash::switches::kSafeMode);
ChromeLabsButtonTest::SetUp();
}
void TearDown() override {
base::CommandLine::ForCurrentProcess()->RemoveSwitch(
ash::switches::kSafeMode);
ChromeLabsButtonTest::TearDown();
}
};
TEST_F(ChromeLabsButtonTestSafeMode, ButtonShouldNotShowTest) {
EXPECT_EQ(browser_view()->toolbar()->GetChromeLabsButton(), nullptr);
}
class ChromeLabsButtonTestSecondaryUser : public ChromeLabsButtonTest {
public:
ChromeLabsButtonTestSecondaryUser() : ChromeLabsButtonTest() {}
void LogIn(const std::string& email) override {
ChromeLabsButtonTest::LogIn("[email protected]");
ChromeLabsButtonTest::LogIn(email);
}
};
TEST_F(ChromeLabsButtonTestSecondaryUser, ButtonShouldNotShowTest) {
EXPECT_EQ(browser_view()->toolbar()->GetChromeLabsButton(), nullptr);
}
#endif
class ChromeLabsButtonNoExperimentsAvailableTest : public TestWithBrowserView { … };
TEST_F(ChromeLabsButtonNoExperimentsAvailableTest, ButtonShouldNotShowTest) { … }
class ChromeLabsButtonOnlyExpiredFeaturesAvailableTest
: public TestWithBrowserView { … };
TEST_F(ChromeLabsButtonOnlyExpiredFeaturesAvailableTest,
ButtonShouldNotShowTest) { … }
#endif