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

Add traces temporarily to track down flakiness in test.

BUG=379170
TBR=asargent

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274316 0039d316-1c4b-4281-b951-d872f2087c98
parent 3b0e466e
......@@ -158,8 +158,13 @@ ExtensionToolbarModel::Action ExtensionToolbarModel::ExecuteBrowserAction(
}
void ExtensionToolbarModel::SetVisibleIconCount(int count) {
LOG(ERROR) << "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_;
// 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).
......@@ -171,16 +176,23 @@ void ExtensionToolbarModel::SetVisibleIconCount(int count) {
void ExtensionToolbarModel::OnExtensionLoaded(
content::BrowserContext* browser_context,
const Extension* extension) {
LOG(ERROR) << "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)
if (toolbar_items_[i].get() == extension) {
LOG(ERROR) << "... but returning early";
return;
}
}
if (ExtensionActionAPI::GetBrowserActionVisibility(extension_prefs_,
extension->id())) {
LOG(ERROR) << "Adding extensions";
AddExtension(extension);
} else {
LOG(ERROR) << "NOT visible";
}
}
......@@ -218,8 +230,10 @@ void ExtensionToolbarModel::Observe(
ExtensionRegistry::EVERYTHING);
if (ExtensionActionAPI::GetBrowserActionVisibility(extension_prefs_,
extension->id())) {
LOG(ERROR) << "Adding extension";
AddExtension(extension);
} else {
LOG(ERROR) << "Removing extension";
RemoveExtension(extension);
}
}
......
......@@ -584,30 +584,33 @@ 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]";
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]";
ASSERT_TRUE(LoadExtension(extension_b_path));
std::string id_a = ExtensionAt(0)->id();
std::string id_b = ExtensionAt(1)->id();
LOG(ERROR) << "GetVisibleIconCount";
// Should be at max size (-1).
EXPECT_EQ(-1, model_->GetVisibleIconCount());
LOG(ERROR) << "OnExtensionToolbarPrefChange";
model_->OnExtensionToolbarPrefChange();
LOG(ERROR) << "GetVisibleIconCount";
// Should still be at max size.
EXPECT_EQ(-1, model_->GetVisibleIconCount());
}
......
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