Commit 995a8267 authored by finnur@chromium.org's avatar finnur@chromium.org

Temporarily re-enabling SizeAfterPrefChange test with traces (this time for Linux only).

BUG=379170
TBR=asargent

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

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