1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576
|
// Copyright 2025 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <math.h>
#include "base/numerics/ranges.h"
#include "cc/test/pixel_test_utils.h"
#include "chrome/browser/glic/browser_ui/glic_tab_underline_view.h"
#include "chrome/browser/glic/host/glic_features.mojom.h"
#include "chrome/browser/glic/test_support/glic_test_util.h"
#include "chrome/browser/glic/test_support/interactive_glic_test.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_element_identifiers.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/tab_strip_region_view.h"
#include "chrome/browser/ui/views/tabs/alert_indicator_button.h"
#include "chrome/browser/ui/views/tabs/glic_button.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/ui_test_utils.h"
#include "chrome/test/interaction/interactive_browser_test.h"
#include "chrome/test/interaction/webcontents_interaction_test_util.h"
#include "components/tabs/public/tab_interface.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/test_navigation_observer.h"
#include "content/public/test/test_utils.h"
#include "gpu/config/gpu_switches.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/base_window.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/base/ozone_buildflags.h"
#include "ui/compositor/compositor_switches.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/switches.h"
#include "ui/views/test/widget_activation_waiter.h"
namespace glic {
namespace {
using DeepQuery = WebContentsInteractionTestUtil::DeepQuery;
static constexpr char kClickFn[] = "el => el.click()";
static constexpr float kFloatComparisonTolerance = 0.001f;
class TesterImpl : public GlicTabUnderlineView::Tester {
public:
TesterImpl() = default;
TesterImpl(const TesterImpl&) = delete;
TesterImpl& operator=(const TesterImpl&) = delete;
~TesterImpl() override = default;
// `underlineView::Tester`:
base::TimeTicks GetTestTimestamp() override { return next_time_tick_; }
base::TimeTicks GetTestCreationTime() override { return creation_time_; }
void AnimationStarted() override {
animation_started_ = true;
wait_for_animation_started_.Quit();
}
void EmphasisRestarted() override {
emphasis_restarted_ = true;
wait_for_emphasis_restarted_.Quit();
}
void RampDownStarted() override {
ramp_down_started_ = true;
wait_for_ramp_down_started_.Quit();
}
void set_underline(GlicTabUnderlineView* underline) {
underline_ = underline;
}
void ResetWaitForAnimationStart() { animation_started_ = false; }
void WaitForAnimationStart() {
if (animation_started_) {
return;
}
SCOPED_TRACE("WaitForAnimationStart");
wait_for_animation_started_.Run();
}
void WaitForEmphasisRestarted() {
if (emphasis_restarted_) {
return;
}
SCOPED_TRACE("WaitForEmphasisRestarted");
wait_for_emphasis_restarted_.Run();
}
void WaitForRampDownStarted() {
if (ramp_down_started_) {
return;
}
SCOPED_TRACE("WaitForRampDownStarted");
wait_for_ramp_down_started_.Run();
}
// Flush out the ramp down animation.
void FinishRampDown() {
// First call records the T0 for ramping down.
AdvanceTimeAndTickAnimation(base::TimeDelta());
AdvanceTimeAndTickAnimation(base::Seconds(2));
}
void AdvanceTimeAndTickAnimation(base::TimeDelta delta) {
static constexpr base::TimeTicks kDummyTimeStamp;
ASSERT_TRUE(underline_);
next_time_tick_ += delta;
underline_->OnAnimationStep(kDummyTimeStamp);
}
private:
const base::TimeTicks creation_time_ = base::TimeTicks::Now();
raw_ptr<GlicTabUnderlineView> underline_;
base::TimeTicks next_time_tick_ = creation_time_;
bool animation_started_ = false;
base::RunLoop wait_for_animation_started_;
bool emphasis_restarted_ = false;
base::RunLoop wait_for_emphasis_restarted_;
bool ramp_down_started_ = false;
base::RunLoop wait_for_ramp_down_started_;
};
class TestUnderlineView : public GlicTabUnderlineView {
public:
TestUnderlineView(Browser* browser, Tab* tab, std::unique_ptr<Tester> tester)
: GlicTabUnderlineView(browser, tab, std::move(tester)) {}
~TestUnderlineView() override = default;
};
class TestFactory : public GlicTabUnderlineView::Factory {
public:
TestFactory() { GlicTabUnderlineView::Factory::set_factory(this); }
~TestFactory() override {
GlicTabUnderlineView::Factory::set_factory(nullptr);
}
protected:
std::unique_ptr<GlicTabUnderlineView> CreateUnderlineView(Browser* browser,
Tab* tab) override {
GlicTabUnderlineView* new_underline =
new TestUnderlineView(browser, tab, std::make_unique<TesterImpl>());
TesterImpl* tester = static_cast<TesterImpl*>(new_underline->tester());
tester->set_underline(new_underline);
return base::WrapUnique(new_underline);
}
};
class GlicTabUnderlineViewUiTest : public test::InteractiveGlicTest {
public:
GlicTabUnderlineViewUiTest() {
const std::string multitab_feature_name =
mojom::features::kGlicMultiTab.name;
const std::string underline_feature_name =
features::kGlicMultitabUnderlines.name;
// Toggling `UiGpuRasterization` is only possible via command line.
const std::string enabled_features =
base::StrCat({multitab_feature_name, ",", underline_feature_name, ",",
"UiGpuRasterization"});
features_.InitFromCommandLine(enabled_features, /*disable_features=*/"");
}
~GlicTabUnderlineViewUiTest() override = default;
void SetUpOnMainThread() override {
embedded_test_server()->ServeFilesFromSourceDirectory(
GetChromeTestDataDir());
test::InteractiveGlicTest::SetUpOnMainThread();
ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), Title1()));
}
void SetUpCommandLine(base::CommandLine* command_line) override {
command_line->AppendSwitch(switches::kForcePrefersNoReducedMotion);
test::InteractiveGlicTest::SetUpCommandLine(command_line);
}
void OpenGlicWindowAndStartSharing() {
const DeepQuery kContextAccessIndicatorCheckBox{
{"#contextAccessIndicator"}};
RunTestSequence(
// See https://crrev.com/c/6373789: the glic window is in detach mode by
// default.
OpenGlicWindow(GlicWindowMode::kDetached),
ExecuteJsAt(test::kGlicContentsElementId,
kContextAccessIndicatorCheckBox, kClickFn));
}
void CloseGlicWindow() {
const DeepQuery kCloseWindowButton{{"#closebn"}};
RunTestSequence(ExecuteJsAt(test::kGlicContentsElementId,
kCloseWindowButton, kClickFn));
}
void AppendTabAndNavigate(Browser* browser, const GURL& url) {
auto new_tab_index = browser->tab_strip_model()->active_index() + 1;
content::TestNavigationObserver navigation_observer(url);
navigation_observer.StartWatchingNewWebContents();
chrome::AddTabAt(browser, url, /*index=*/new_tab_index,
/*foreground=*/false);
navigation_observer.Wait();
browser->tab_strip_model()->ActivateTabAt(new_tab_index);
}
GURL Title1() const { return embedded_test_server()->GetURL("/title1.html"); }
GURL Title2() const { return embedded_test_server()->GetURL("/title2.html"); }
GlicTabUnderlineView* GetUnderlineOfActiveTab() {
auto* tabstrip = static_cast<BrowserView*>(browser()->window())->tabstrip();
return tabstrip->tab_at(tabstrip->GetActiveIndex().value())
->glic_underline();
}
content::WebContents* GetActiveWebContents() {
return browser()->GetTabStripModel()->GetActiveWebContents();
}
void ActivateTabAt(int index) {
browser()->GetTabStripModel()->ActivateTabAt(index);
}
glic::GlicSharingManager& sharing_manager() {
return glic::GlicKeyedServiceFactory::GetGlicKeyedService(
browser()->GetProfile())
->sharing_manager();
}
tabs::TabHandle TabHandleAtIndex(int index) {
return browser()->tab_strip_model()->GetTabAtIndex(index)->GetHandle();
}
void PinTabs(base::span<const tabs::TabHandle> tab_handles) {
sharing_manager().PinTabs(tab_handles);
}
AlertIndicatorButton* GetAlertIndicatorButtonOfActiveTab() {
auto* tabstrip = static_cast<BrowserView*>(browser()->window())->tabstrip();
return tabstrip->tab_at(tabstrip->GetActiveIndex().value())
->alert_indicator_button_for_testing();
}
private:
base::test::ScopedFeatureList features_;
TestFactory test_factory_;
};
} // namespace
// Exercise the default user journey: toggles the underline animation and waits
// for it to finish.
IN_PROC_BROWSER_TEST_F(GlicTabUnderlineViewUiTest, SmokeTest) {
auto* underline = GetUnderlineOfActiveTab();
ASSERT_TRUE(underline);
TesterImpl* tester = static_cast<TesterImpl*>(underline->tester());
OpenGlicWindowAndStartSharing();
tester->WaitForAnimationStart();
EXPECT_TRUE(underline->IsShowing());
// Manually stepping the animation code to mimic the behavior of the
// compositor. These tests follow the same setup as GlicBorderViewUiTest. For
// those tests, crbug.com/384712084 and crbug.com/387386303 outline how
// testing via requesting screenshot from the browser window was explored but
// ultimately failed due to test flakiness. These tests follow the same
// workarounds, improvement is outlined in
// TODO(crbug.com/crbug.com/387386303).
// T=0s.
tester->AdvanceTimeAndTickAnimation(base::TimeDelta());
EXPECT_NEAR(underline->opacity_for_testing(), 0.f, kFloatComparisonTolerance);
EXPECT_NEAR(underline->emphasis_for_testing(), 0.f,
kFloatComparisonTolerance);
EXPECT_NEAR(underline->progress_for_testing(), 0.f,
kFloatComparisonTolerance);
// T=0.333s.
tester->AdvanceTimeAndTickAnimation(base::Seconds(0.333));
// 0.333/0.5.
EXPECT_NEAR(underline->opacity_for_testing(), 0.666,
kFloatComparisonTolerance);
// 0.333/0.5=0.666, 1-(1-0.666)**2~=0.888
EXPECT_NEAR(underline->emphasis_for_testing(), 0.888,
kFloatComparisonTolerance);
// 0.333/3
EXPECT_NEAR(underline->progress_for_testing(), 0.111f,
kFloatComparisonTolerance);
// T=1.333s
tester->AdvanceTimeAndTickAnimation(base::Seconds(1));
// Opacity ramp up is 0.5s.
EXPECT_NEAR(underline->opacity_for_testing(), 1.f, kFloatComparisonTolerance);
// clamped 1.333/0.5 -> 1.0, 1-(1-1.0.667)**2=1.0
EXPECT_NEAR(underline->emphasis_for_testing(), 1.f,
kFloatComparisonTolerance);
// 1.333/3
EXPECT_NEAR(underline->progress_for_testing(), 0.444f,
kFloatComparisonTolerance);
// T=2.433s
tester->AdvanceTimeAndTickAnimation(base::Seconds(1.1));
EXPECT_NEAR(underline->opacity_for_testing(), 1.f, kFloatComparisonTolerance);
// (2.433-2)/1.0=0.433
EXPECT_NEAR(
underline->emphasis_for_testing(),
1.f - gfx::Tween::CalculateValue(gfx::Tween::Type::EASE_IN_OUT_2, 0.433),
kFloatComparisonTolerance);
// 2.433/3
EXPECT_NEAR(underline->progress_for_testing(), 0.811,
kFloatComparisonTolerance);
CloseGlicWindow();
tester->WaitForRampDownStarted();
tester->FinishRampDown();
EXPECT_FALSE(underline->IsShowing());
}
IN_PROC_BROWSER_TEST_F(GlicTabUnderlineViewUiTest, ToggleSharingWithSingleTab) {
auto* underline = GetUnderlineOfActiveTab();
TesterImpl* tester = static_cast<TesterImpl*>(underline->tester());
EXPECT_FALSE(underline->IsShowing());
RunTestSequence(OpenGlicWindow(GlicWindowMode::kDetached));
EXPECT_TRUE(glic_service()->IsWindowShowing());
// The underline should show when sharing is turned on.
glic_service()->SetContextAccessIndicator(true);
EXPECT_TRUE(
glic_service()->IsContextAccessIndicatorShown(GetActiveWebContents()));
tester->WaitForAnimationStart();
EXPECT_TRUE(underline->IsShowing());
tester->AdvanceTimeAndTickAnimation(base::TimeDelta());
tester->AdvanceTimeAndTickAnimation(base::Seconds(0.3));
// The underline should hide when sharing is turned off.
glic_service()->SetContextAccessIndicator(false);
ASSERT_FALSE(
glic_service()->IsContextAccessIndicatorShown(GetActiveWebContents()));
tester->WaitForRampDownStarted();
tester->FinishRampDown();
EXPECT_FALSE(underline->IsShowing());
}
IN_PROC_BROWSER_TEST_F(GlicTabUnderlineViewUiTest,
SingleTabPinningWhileGlicWindowOpen) {
RunTestSequence(OpenGlicWindow(GlicWindowMode::kDetached));
EXPECT_TRUE(glic_service()->IsWindowShowing());
auto* underline = GetUnderlineOfActiveTab();
TesterImpl* tester = static_cast<TesterImpl*>(underline->tester());
EXPECT_FALSE(underline->IsShowing());
// The underline should show when its tab is pinned.
tabs::TabHandle tab_handle = TabHandleAtIndex(0);
PinTabs({tab_handle});
ASSERT_TRUE(sharing_manager().IsTabPinned(tab_handle));
tester->WaitForAnimationStart();
EXPECT_TRUE(underline->IsShowing());
tester->AdvanceTimeAndTickAnimation(base::TimeDelta());
tester->AdvanceTimeAndTickAnimation(base::Seconds(0.3));
// The underline should hide when its tab is unpinned.
sharing_manager().UnpinAllTabs();
ASSERT_FALSE(sharing_manager().IsTabPinned(tab_handle));
tester->WaitForRampDownStarted();
tester->FinishRampDown();
EXPECT_FALSE(underline->IsShowing());
}
IN_PROC_BROWSER_TEST_F(GlicTabUnderlineViewUiTest,
SingleTabPinningWhileGlicWindowClosed) {
EXPECT_FALSE(glic_service()->IsWindowShowing());
// While the glic window is closed, changes to pinning have no effect on the
// underline UI.
auto* underline = GetUnderlineOfActiveTab();
tabs::TabHandle tab_handle = TabHandleAtIndex(0);
PinTabs({tab_handle});
EXPECT_TRUE(sharing_manager().IsTabPinned(tab_handle));
EXPECT_FALSE(underline->IsShowing());
sharing_manager().UnpinAllTabs();
ASSERT_FALSE(sharing_manager().IsTabPinned(tab_handle));
EXPECT_FALSE(underline->IsShowing());
}
IN_PROC_BROWSER_TEST_F(GlicTabUnderlineViewUiTest,
ToggleGlicWindowVisibilityWithPinnedTab) {
auto* underline = GetUnderlineOfActiveTab();
TesterImpl* tester = static_cast<TesterImpl*>(underline->tester());
tabs::TabHandle tab_handle = TabHandleAtIndex(0);
PinTabs({tab_handle});
EXPECT_TRUE(sharing_manager().IsTabPinned(tab_handle));
// The underline of a pinned tab should show when the glic window is opened.
RunTestSequence(OpenGlicWindow(GlicWindowMode::kDetached));
tester->WaitForAnimationStart();
EXPECT_TRUE(underline->IsShowing());
tester->AdvanceTimeAndTickAnimation(base::TimeDelta());
tester->AdvanceTimeAndTickAnimation(base::Seconds(0.3));
// The underline of a pinned tab should hide when the glic window is closed.
CloseGlicWindow();
tester->WaitForRampDownStarted();
tester->FinishRampDown();
EXPECT_FALSE(underline->IsShowing());
}
IN_PROC_BROWSER_TEST_F(GlicTabUnderlineViewUiTest, FocusedTabChange) {
auto* underline1 = GetUnderlineOfActiveTab();
TesterImpl* tester1 = static_cast<TesterImpl*>(underline1->tester());
// Add second tab
AppendTabAndNavigate(browser(), Title2());
auto* underline2 = GetUnderlineOfActiveTab();
TesterImpl* tester2 = static_cast<TesterImpl*>(underline2->tester());
// The underline of the active tab should show when sharing is turned on.
OpenGlicWindowAndStartSharing();
tester2->WaitForAnimationStart();
EXPECT_TRUE(underline2->IsShowing());
tester2->AdvanceTimeAndTickAnimation(base::TimeDelta());
tester2->AdvanceTimeAndTickAnimation(base::Seconds(0.3));
// For tabs that are not pinned while sharing is turned on, the underline of a
// tab that loses focus should hide and the underline of a tab that gains
// focus should show.
ActivateTabAt(0);
tester1->WaitForAnimationStart();
EXPECT_TRUE(underline1->IsShowing());
tester1->AdvanceTimeAndTickAnimation(base::TimeDelta());
tester1->AdvanceTimeAndTickAnimation(base::Seconds(0.3));
tester2->WaitForRampDownStarted();
tester2->FinishRampDown();
EXPECT_FALSE(underline2->IsShowing());
}
IN_PROC_BROWSER_TEST_F(GlicTabUnderlineViewUiTest,
FocusedTabChangeBetweenPinnedTabs) {
auto* underline1 = GetUnderlineOfActiveTab();
TesterImpl* tester1 = static_cast<TesterImpl*>(underline1->tester());
AppendTabAndNavigate(browser(), Title2());
auto* underline2 = GetUnderlineOfActiveTab();
TesterImpl* tester2 = static_cast<TesterImpl*>(underline2->tester());
// Pin both tabs
PinTabs({TabHandleAtIndex(0), TabHandleAtIndex(1)});
EXPECT_TRUE(sharing_manager().IsTabPinned(TabHandleAtIndex(0)));
EXPECT_TRUE(sharing_manager().IsTabPinned(TabHandleAtIndex(1)));
// Underlines of all pinned tabs should show when the glic window is opened.
RunTestSequence(OpenGlicWindow(GlicWindowMode::kDetached));
tester1->WaitForAnimationStart();
tester2->WaitForAnimationStart();
EXPECT_TRUE(underline1->IsShowing());
EXPECT_TRUE(underline2->IsShowing());
// Allow animations to reach their steady states.
tester1->AdvanceTimeAndTickAnimation(base::TimeDelta());
tester1->AdvanceTimeAndTickAnimation(base::Seconds(3));
tester2->AdvanceTimeAndTickAnimation(base::TimeDelta());
tester2->AdvanceTimeAndTickAnimation(base::Seconds(3));
// Grab current animation values for later comparison.
float u1_opacity = underline1->opacity_for_testing();
float u2_opacity = underline2->opacity_for_testing();
// While sharing is off, changing focus between pinned tabs should have no
// visual effect on their underlines.
ActivateTabAt(0);
tester1->AdvanceTimeAndTickAnimation(base::TimeDelta());
tester2->AdvanceTimeAndTickAnimation(base::TimeDelta());
EXPECT_TRUE(underline1->IsShowing());
EXPECT_TRUE(underline2->IsShowing());
EXPECT_EQ(underline1->opacity_for_testing(), u1_opacity);
EXPECT_EQ(underline2->opacity_for_testing(), u2_opacity);
}
IN_PROC_BROWSER_TEST_F(GlicTabUnderlineViewUiTest, TabAlertIndicatorHidden) {
auto* underline = GetUnderlineOfActiveTab();
ASSERT_TRUE(underline);
TesterImpl* tester = static_cast<TesterImpl*>(underline->tester());
OpenGlicWindowAndStartSharing();
tester->WaitForAnimationStart();
EXPECT_TRUE(underline->IsShowing());
// The shared tab should not have a visible tab alert indicator.
EXPECT_FALSE(GetAlertIndicatorButtonOfActiveTab()->GetVisible());
}
IN_PROC_BROWSER_TEST_F(GlicTabUnderlineViewUiTest,
TabAlertIndicatorHidden_PinnedTab) {
RunTestSequence(OpenGlicWindow(GlicWindowMode::kDetached));
EXPECT_TRUE(glic_service()->IsWindowShowing());
auto* underline = GetUnderlineOfActiveTab();
TesterImpl* tester = static_cast<TesterImpl*>(underline->tester());
EXPECT_FALSE(underline->IsShowing());
tabs::TabHandle tab_handle = TabHandleAtIndex(0);
PinTabs({tab_handle});
ASSERT_TRUE(sharing_manager().IsTabPinned(tab_handle));
tester->WaitForAnimationStart();
EXPECT_TRUE(underline->IsShowing());
// The pinned tab should not have a visible tab alert indicator.
EXPECT_FALSE(GetAlertIndicatorButtonOfActiveTab()->GetVisible());
}
namespace {
class GlicTabUnderlineViewFeatureDisabledBrowserTest
: public GlicTabUnderlineViewUiTest {
public:
GlicTabUnderlineViewFeatureDisabledBrowserTest() {
features_.InitAndDisableFeature(features::kGlicMultitabUnderlines);
}
~GlicTabUnderlineViewFeatureDisabledBrowserTest() override = default;
private:
base::test::ScopedFeatureList features_;
};
} // namespace
IN_PROC_BROWSER_TEST_F(GlicTabUnderlineViewFeatureDisabledBrowserTest,
TabAlertIndicatorShown) {
AlertIndicatorButton* alert_button = GetAlertIndicatorButtonOfActiveTab();
EXPECT_FALSE(alert_button->GetVisible());
base::RunLoop wait_for_alert_loop;
auto callback_subscription = alert_button->AddVisibleChangedCallback(
wait_for_alert_loop.QuitClosure());
OpenGlicWindowAndStartSharing();
tabs::TabInterface* tab = browser()->tab_strip_model()->GetTabAtIndex(0);
ASSERT_EQ(tab, sharing_manager().GetFocusedTabData().focus());
// Wait for the view's visibility change to trigger.
wait_for_alert_loop.Run();
// The shared tab should have a visible tab alert indicator.
EXPECT_TRUE(alert_button->GetVisible());
}
IN_PROC_BROWSER_TEST_F(GlicTabUnderlineViewFeatureDisabledBrowserTest,
TabAlertIndicatorShown_PinnedTab) {
AlertIndicatorButton* alert_button = GetAlertIndicatorButtonOfActiveTab();
EXPECT_FALSE(alert_button->GetVisible());
RunTestSequence(OpenGlicWindow(GlicWindowMode::kDetached));
EXPECT_TRUE(glic_service()->IsWindowShowing());
base::RunLoop wait_for_alert_loop;
auto callback_subscription = alert_button->AddVisibleChangedCallback(
wait_for_alert_loop.QuitClosure());
tabs::TabHandle tab_handle = TabHandleAtIndex(0);
PinTabs({tab_handle});
ASSERT_TRUE(sharing_manager().IsTabPinned(tab_handle));
// Wait for the view's visibility change to trigger.
wait_for_alert_loop.Run();
// The pinned tab should have a visible tab alert indicator.
EXPECT_TRUE(GetAlertIndicatorButtonOfActiveTab()->GetVisible());
}
} // namespace glic
|