Commit fbdca2cd authored by sky's avatar sky Committed by Commit bot

Fixes bug where shelf items could be added for children windows

WindowObserver::OnWindowVisibilityChanged() is called any time the
visibility of a descendant changes. This means if the visibility of a
child of a window shown on the shelf changes and the child's type is other
than none, then an entry is added to the shelf. I don't believe this would
happen for aura, but for mus the default type is TYPE_APP (unless
explicitly set).

BUG=none
TEST=covered by test
R=msw@chromium.org

Review-Url: https://codereview.chromium.org/2576023002
Cr-Commit-Position: refs/heads/master@{#438622}
parent a6de3464
......@@ -100,6 +100,11 @@ void ShelfWindowWatcher::UserWindowObserver::OnWindowDestroying(
void ShelfWindowWatcher::UserWindowObserver::OnWindowVisibilityChanged(
WmWindow* window,
bool visible) {
// OnWindowVisibilityChanged() is called for descendants too. We only care
// about changes to the visibility of windows we know about.
if (!window_watcher_->observed_user_windows_.IsObserving(window))
return;
// The tooltip behavior for panel windows depends on the panel visibility.
window_watcher_->OnUserWindowPropertyChanged(window);
}
......
......@@ -307,4 +307,30 @@ TEST_F(ShelfWindowWatcherTest, PanelWindow) {
EXPECT_EQ(1, model_->item_count());
}
TEST_F(ShelfWindowWatcherTest, DontCreateShelfEntriesForChildWindows) {
const int initial_item_count = model_->item_count();
WmWindow* window = WmShell::Get()->NewWindow(ui::wm::WINDOW_TYPE_NORMAL,
ui::LAYER_NOT_DRAWN);
window->SetIntProperty(WmWindowProperty::SHELF_ITEM_TYPE, TYPE_APP);
WmShell::Get()
->GetPrimaryRootWindow()
->GetChildByShellWindowId(kShellWindowId_DefaultContainer)
->AddChild(window);
window->Show();
EXPECT_EQ(initial_item_count + 1, model_->item_count());
WmWindow* child_window = WmShell::Get()->NewWindow(ui::wm::WINDOW_TYPE_NORMAL,
ui::LAYER_NOT_DRAWN);
child_window->SetIntProperty(WmWindowProperty::SHELF_ITEM_TYPE, TYPE_APP);
window->AddChild(child_window);
child_window->Show();
// |child_window| should not result in adding a new entry.
EXPECT_EQ(initial_item_count + 1, model_->item_count());
child_window->Destroy();
window->Destroy();
EXPECT_EQ(initial_item_count, model_->item_count());
}
} // namespace ash
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