Commit 15f7f9e8 authored by Bret Sepulveda's avatar Bret Sepulveda Committed by Commit Bot

Add debug logging for DialogBrowserTest suites.

This patch adds some additional logging for two scenarios:
* When TestBrowserDialog::VerifyUi reports that >1 Widget was added, we
  will log the titles of all the Widgets that were added.
* Added some DCHECKs that will hopefully produce a stack trace if
  ExtensionsMenuItemView fails to be constructed or is destructed before
  TestBrowserDialog::VerifyUi runs.

I intend to revert this patch after the associated bug is fixed.

Bug: 1050012
Change-Id: If9f86ee91ff748b1a73b979d4961cd3d04496798
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2043800
Commit-Queue: Bret Sepulveda <bsep@chromium.org>
Auto-Submit: Bret Sepulveda <bsep@chromium.org>
Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/master@{#740262}
parent bca1d900
......@@ -8,6 +8,7 @@
#include "base/logging.h"
#include "base/run_loop.h"
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "chrome/test/pixel/browser_skia_gold_pixel_diff.h"
......@@ -96,6 +97,15 @@ bool TestBrowserDialog::VerifyUi() {
if (added.size() != 1) {
DLOG(INFO) << "VerifyUi(): Expected 1 added widget; got " << added.size();
if (added.size() > 1) {
base::string16 widget_title_log =
base::ASCIIToUTF16("Added Widgets are: ");
for (views::Widget* widget : added) {
widget_title_log += widget->widget_delegate()->GetWindowTitle() +
base::ASCIIToUTF16(" ");
}
DLOG(INFO) << widget_title_log;
}
return false;
}
......
......@@ -125,6 +125,10 @@ gfx::Size ExtensionsMenuView::CalculatePreferredSize() const {
return gfx::Size(width, GetHeightForWidth(width));
}
void ExtensionsMenuView::WindowClosing() {
DCHECK(!crash_on_close_for_testing_);
}
void ExtensionsMenuView::Populate() {
// The actions for the profile haven't been initialized yet. We'll call in
// again once they have.
......
......@@ -55,6 +55,10 @@ class ExtensionsMenuView : public views::BubbleDialogDelegateView,
// Returns the currently-showing ExtensionsMenuView, if any exists.
static ExtensionsMenuView* GetExtensionsMenuViewForTesting();
void set_crash_on_close_for_testing(bool value) {
crash_on_close_for_testing_ = value;
}
// views::BubbleDialogDelegateView:
base::string16 GetWindowTitle() const override;
bool ShouldShowCloseButton() const override;
......@@ -62,6 +66,7 @@ class ExtensionsMenuView : public views::BubbleDialogDelegateView,
// contrain the width. It would be nice to have a unified way of getting the
// preferred size to not duplicate the code.
gfx::Size CalculatePreferredSize() const override;
void WindowClosing() override;
// TabStripModelObserver:
void TabChangedAt(content::WebContents* contents,
......@@ -180,6 +185,11 @@ class ExtensionsMenuView : public views::BubbleDialogDelegateView,
views::Button* manage_extensions_button_for_testing_ = nullptr;
// When true, crashes if the Widget closes.
// TODO(crbug.com/1050012): Remove this debug logging when we figure out why
// no new Widget is found in TestBrowserDialog::VerifyUi.
bool crash_on_close_for_testing_ = false;
// The different sections in the menu.
Section cant_access_;
Section wants_access_;
......
......@@ -98,6 +98,10 @@ class ExtensionsMenuViewBrowserTest : public ExtensionsToolbarBrowserTest {
SkBitmap());
} else {
ClickExtensionsMenuButton();
ExtensionsMenuView* menu =
ExtensionsMenuView::GetExtensionsMenuViewForTesting();
DCHECK(menu);
menu->set_crash_on_close_for_testing(true);
}
// Wait for any pending animations to finish so that correct pinned
......@@ -125,6 +129,9 @@ class ExtensionsMenuViewBrowserTest : public ExtensionsToolbarBrowserTest {
EXPECT_TRUE(container->IsActionVisibleOnToolbar(
container->GetActionForId(extensions()[0]->id())));
EXPECT_TRUE(container->GetViewForId(extensions()[0]->id())->GetVisible());
} else {
ExtensionsMenuView::GetExtensionsMenuViewForTesting()
->set_crash_on_close_for_testing(false);
}
return true;
......
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