Commit 983836cd authored by Alan Cutter's avatar Alan Cutter Committed by Commit Bot

desktop-pwas: Fix CustomTabBar showing incorrectly in tabbed PWA windows

This CL ensures we update the visibility of the CustomTabBar when tabbed
PWA windows switch tabs.

Before: https://bugs.chromium.org/p/chromium/issues/attachment?aid=444139&signed_aid=nl_zCuHmhPys4eSWxjVDmQ==&inline=1
After: https://bugs.chromium.org/p/chromium/issues/attachment?aid=444368&signed_aid=6ab3-VByQm9JLc76qLpHDQ==&inline=1

Bug: 1076721
Change-Id: Ib4957e721e6c08f42df7297ddd397bac01e9f728
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2175696
Commit-Queue: Alan Cutter <alancutter@chromium.org>
Auto-Submit: Alan Cutter <alancutter@chromium.org>
Reviewed-by: default avatarJoel Hockey <joelhockey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#765421}
parent b1524abc
......@@ -3,9 +3,13 @@
// found in the LICENSE file.
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/location_bar/custom_tab_bar_view.h"
#include "chrome/browser/ui/views/tabs/tab_strip.h"
#include "chrome/browser/ui/views/toolbar/toolbar_view.h"
#include "chrome/browser/ui/web_applications/app_browser_controller.h"
#include "chrome/browser/ui/web_applications/test/web_app_browsertest_util.h"
#include "chrome/browser/web_applications/components/app_registry_controller.h"
......@@ -15,6 +19,7 @@
#include "chrome/common/web_application_info.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_utils.h"
#include "content/public/test/theme_change_waiter.h"
......@@ -34,6 +39,60 @@ class WebAppTabStripBrowserTest : public InProcessBrowserTest {
base::test::ScopedFeatureList features_;
};
IN_PROC_BROWSER_TEST_F(WebAppTabStripBrowserTest,
CustomTabBarUpdateOnTabSwitch) {
Profile* profile = browser()->profile();
ASSERT_TRUE(embedded_test_server()->Start());
GURL app_url = embedded_test_server()->GetURL("/web_apps/basic.html");
auto web_app_info = std::make_unique<WebApplicationInfo>();
web_app_info->app_url = app_url;
web_app_info->scope = embedded_test_server()->GetURL("/web_apps");
web_app_info->title = base::ASCIIToUTF16("Test app");
web_app_info->open_as_window = true;
AppId app_id = InstallWebApp(profile, std::move(web_app_info));
WebAppProviderBase::GetProviderBase(profile)
->registry_controller()
.SetExperimentalTabbedWindowMode(app_id, true);
Browser* app_browser = LaunchWebAppBrowser(profile, app_id);
CustomTabBarView* custom_tab_bar =
BrowserView::GetBrowserViewForBrowser(app_browser)
->toolbar()
->custom_tab_bar();
EXPECT_FALSE(custom_tab_bar->GetVisible());
// Add second tab.
chrome::NewTab(app_browser);
ASSERT_EQ(app_browser->tab_strip_model()->count(), 2);
// Navigate tab out of scope, custom tab bar should appear.
GURL out_of_scope_url =
embedded_test_server()->GetURL("/banners/theme-color.html");
ASSERT_TRUE(content::NavigateToURL(
app_browser->tab_strip_model()->GetActiveWebContents(),
out_of_scope_url));
EXPECT_EQ(
app_browser->tab_strip_model()->GetActiveWebContents()->GetVisibleURL(),
out_of_scope_url);
EXPECT_TRUE(custom_tab_bar->GetVisible());
// Custom tab bar should go away for in scope tab.
chrome::SelectNextTab(app_browser);
EXPECT_EQ(
app_browser->tab_strip_model()->GetActiveWebContents()->GetVisibleURL(),
app_url);
EXPECT_FALSE(custom_tab_bar->GetVisible());
// Custom tab bar should return for out of scope tab.
chrome::SelectNextTab(app_browser);
EXPECT_EQ(
app_browser->tab_strip_model()->GetActiveWebContents()->GetVisibleURL(),
out_of_scope_url);
EXPECT_TRUE(custom_tab_bar->GetVisible());
}
IN_PROC_BROWSER_TEST_F(WebAppTabStripBrowserTest, TabThemeColor) {
Profile* profile = browser()->profile();
......
......@@ -412,6 +412,7 @@ void AppBrowserController::OnTabStripModelChanged(
// WebContents should be null when the last tab is closed.
DCHECK_EQ(web_contents() == nullptr, tab_strip_model->empty());
}
UpdateCustomTabBarVisibility(/*animate=*/false);
}
CustomThemeSupplier* AppBrowserController::GetThemeSupplier() const {
......
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