Commit eab3d03a authored by finnur@chromium.org's avatar finnur@chromium.org

Temporarily re-enabling SizeAfterPrefChange test with traces.

BUG=379170
TBR=asargent

Review URL: https://codereview.chromium.org/318483002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274606 0039d316-1c4b-4281-b951-d872f2087c98
parent 0e3f2d23
......@@ -158,13 +158,13 @@ ExtensionToolbarModel::Action ExtensionToolbarModel::ExecuteBrowserAction(
}
void ExtensionToolbarModel::SetVisibleIconCount(int count) {
LOG(ERROR) << "visible_icon_count_ before: " << visible_icon_count_;
VLOG(4) << "visible_icon_count_ before: " << visible_icon_count_;
visible_icon_count_ =
count == static_cast<int>(toolbar_items_.size()) ? -1 : count;
LOG(ERROR) << "SetVisibleIconCount "
<< count << " == " << toolbar_items_.size() << " -> "
<< visible_icon_count_ << " "
<< "is_highlighting: " << is_highlighting_;
VLOG(4) << "SetVisibleIconCount "
<< count << " == " << toolbar_items_.size() << " -> "
<< visible_icon_count_ << " "
<< "is_highlighting: " << is_highlighting_;
// Only set the prefs if we're not in highlight mode. Highlight mode is
// designed to be a transitory state, and should not persist across browser
// restarts (though it may be re-entered).
......@@ -176,23 +176,23 @@ void ExtensionToolbarModel::SetVisibleIconCount(int count) {
void ExtensionToolbarModel::OnExtensionLoaded(
content::BrowserContext* browser_context,
const Extension* extension) {
LOG(ERROR) << "Loading extension";
VLOG(4) << "Loading extension";
// We don't want to add the same extension twice. It may have already been
// added by EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED below, if the user
// hides the browser action and then disables and enables the extension.
for (size_t i = 0; i < toolbar_items_.size(); i++) {
if (toolbar_items_[i].get() == extension) {
LOG(ERROR) << "... but returning early";
VLOG(4) << "... but returning early";
return;
}
}
if (ExtensionActionAPI::GetBrowserActionVisibility(extension_prefs_,
extension->id())) {
LOG(ERROR) << "Adding extensions";
VLOG(4) << "Adding extensions";
AddExtension(extension);
} else {
LOG(ERROR) << "NOT visible";
VLOG(4) << "NOT visible";
}
}
......@@ -230,15 +230,16 @@ void ExtensionToolbarModel::Observe(
ExtensionRegistry::EVERYTHING);
if (ExtensionActionAPI::GetBrowserActionVisibility(extension_prefs_,
extension->id())) {
LOG(ERROR) << "Adding extension";
VLOG(4) << "Adding extension";
AddExtension(extension);
} else {
LOG(ERROR) << "Removing extension";
VLOG(4) << "Removing extension";
RemoveExtension(extension);
}
}
void ExtensionToolbarModel::OnReady() {
VLOG(4) << "OnReady called";
ExtensionRegistry* registry = ExtensionRegistry::Get(profile_);
InitializeExtensionList(registry->enabled_extensions());
// Wait until the extension system is ready before observing any further
......@@ -352,6 +353,7 @@ void ExtensionToolbarModel::InitializeExtensionList(
last_known_positions_ = extension_prefs_->GetToolbarOrder();
Populate(last_known_positions_, extensions);
VLOG(4) << "extensions_initialized!";
extensions_initialized_ = true;
FOR_EACH_OBSERVER(Observer, observers_, VisibleCountChanged());
}
......
......@@ -27,6 +27,12 @@ class ExtensionToolbarModelTest : public ExtensionBrowserTest,
ExtensionBrowserTest::SetUp();
}
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
ExtensionBrowserTest::SetUpCommandLine(command_line);
command_line->AppendSwitchNative(
"vmodule", "*extension_toolbar_model*=4,*browser_actions_container*=4");
}
virtual void SetUpOnMainThread() OVERRIDE {
model_ = ExtensionToolbarModel::Get(browser()->profile());
model_->AddObserver(this);
......@@ -584,36 +590,32 @@ IN_PROC_BROWSER_TEST_F(ExtensionToolbarModelTest, HighlightModeAdd) {
EXPECT_EQ(id_c, ExtensionAt(2)->id());
}
// Test is flaky on Linus and ChromeOS, see crbug.com/379170.
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
#define MAYBE_SizeAfterPrefChange DISABLED_SizeAfterPrefChange
#else
#define MAYBE_SizeAfterPrefChange SizeAfterPrefChange
#endif
IN_PROC_BROWSER_TEST_F(ExtensionToolbarModelTest, MAYBE_SizeAfterPrefChange) {
// Test is flaky (see crbug.com/379170), but currently enabled to gather traces.
// If it fails, ping Finnur.
IN_PROC_BROWSER_TEST_F(ExtensionToolbarModelTest, SizeAfterPrefChange) {
// Load two extensions with browser action.
base::FilePath extension_a_path(test_data_dir_.AppendASCII("api_test")
.AppendASCII("browser_action")
.AppendASCII("basics"));
LOG(ERROR) << "Loading [basics]";
VLOG(4) << "Loading [basics]";
ASSERT_TRUE(LoadExtension(extension_a_path));
base::FilePath extension_b_path(test_data_dir_.AppendASCII("api_test")
.AppendASCII("browser_action")
.AppendASCII("popup"));
LOG(ERROR) << "Loading [popup]";
VLOG(4) << "Loading [popup]";
ASSERT_TRUE(LoadExtension(extension_b_path));
std::string id_a = ExtensionAt(0)->id();
std::string id_b = ExtensionAt(1)->id();
LOG(ERROR) << "GetVisibleIconCount";
VLOG(4) << "GetVisibleIconCount";
// Should be at max size (-1).
EXPECT_EQ(-1, model_->GetVisibleIconCount());
LOG(ERROR) << "OnExtensionToolbarPrefChange";
VLOG(4) << "OnExtensionToolbarPrefChange";
model_->OnExtensionToolbarPrefChange();
LOG(ERROR) << "GetVisibleIconCount";
VLOG(4) << "GetVisibleIconCount";
// Should still be at max size.
EXPECT_EQ(-1, model_->GetVisibleIconCount());
......
......@@ -184,6 +184,8 @@ size_t BrowserActionsContainer::VisibleBrowserActions() const {
if (browser_action_views_[i]->visible())
++visible_actions;
}
VLOG(4) << "BAC::VisibleBrowserActions() returns " << visible_actions
<< " with size=" << browser_action_views_.size();
return visible_actions;
}
......@@ -672,10 +674,13 @@ void BrowserActionsContainer::BrowserActionAdded(const Extension* extension,
#endif
CloseOverflowMenu();
if (!ShouldDisplayBrowserAction(extension))
if (!ShouldDisplayBrowserAction(extension)) {
VLOG(4) << "Should not display: " << extension->name().c_str();
return;
}
size_t visible_actions = VisibleBrowserActions();
VLOG(4) << "Got back " << visible_actions << " visible.";
// Add the new browser action to the vector and the view hierarchy.
if (profile_->IsOffTheRecord())
......@@ -685,17 +690,21 @@ void BrowserActionsContainer::BrowserActionAdded(const Extension* extension,
AddChildViewAt(view, index);
// If we are still initializing the container, don't bother animating.
if (!model_->extensions_initialized())
if (!model_->extensions_initialized()) {
VLOG(4) << "Still initializing";
return;
}
// Enlarge the container if it was already at maximum size and we're not in
// the middle of upgrading.
if ((model_->GetVisibleIconCount() < 0) &&
!extensions::ExtensionSystem::Get(profile_)->runtime_data()->
IsBeingUpgraded(extension)) {
VLOG(4) << "At max, Save and animate";
suppress_chevron_ = true;
SaveDesiredSizeAndAnimate(gfx::Tween::LINEAR, visible_actions + 1);
} else {
VLOG(4) << "Not at max";
// Just redraw the (possibly modified) visible icon set.
OnBrowserActionVisibilityChanged();
}
......@@ -871,9 +880,12 @@ void BrowserActionsContainer::SaveDesiredSizeAndAnimate(
// NOTE: Don't save the icon count in incognito because there may be fewer
// icons in that mode. The result is that the container in a normal window is
// always at least as wide as in an incognito window.
if (!profile_->IsOffTheRecord())
if (!profile_->IsOffTheRecord()) {
model_->SetVisibleIconCount(num_visible_icons);
VLOG(4) << "Setting visible count: " << num_visible_icons;
} else {
VLOG(4) << "|Skipping| setting visible count: " << num_visible_icons;
}
int target_size = IconCountToWidth(num_visible_icons,
num_visible_icons < browser_action_views_.size());
if (!disable_animations_during_testing_) {
......
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