| Index: ash/shelf/shelf_window_watcher_unittest.cc
|
| diff --git a/ash/shelf/shelf_window_watcher_unittest.cc b/ash/shelf/shelf_window_watcher_unittest.cc
|
| index b02928f5cf89452eafe66eda6014c3466bb3dba2..556fc5389126549eba1ebffbaac418a172d900b5 100644
|
| --- a/ash/shelf/shelf_window_watcher_unittest.cc
|
| +++ b/ash/shelf/shelf_window_watcher_unittest.cc
|
| @@ -25,6 +25,7 @@
|
| #include "ui/gfx/image/image_skia.h"
|
| #include "ui/resources/grit/ui_resources.h"
|
| #include "ui/views/widget/widget.h"
|
| +#include "ui/wm/core/transient_window_controller.h"
|
|
|
| namespace ash {
|
| namespace {
|
| @@ -72,7 +73,7 @@ TEST_F(ShelfWindowWatcherTest, OpenAndClose) {
|
| // ShelfModel only has an APP_LIST item.
|
| EXPECT_EQ(1, model_->item_count());
|
|
|
| - // Adding windows with valid ShelfItemType properties adds shelf items.
|
| + // Windows with valid ShelfItemType and ShelfID properties get shelf items.
|
| std::unique_ptr<views::Widget> widget1 =
|
| CreateTestWidget(nullptr, kShellWindowId_DefaultContainer, gfx::Rect());
|
| CreateShelfItem(widget1->GetNativeWindow());
|
| @@ -89,6 +90,38 @@ TEST_F(ShelfWindowWatcherTest, OpenAndClose) {
|
| EXPECT_EQ(1, model_->item_count());
|
| }
|
|
|
| +// Ensure shelf items are added and removed for unknown windows in mash.
|
| +TEST_F(ShelfWindowWatcherTest, OpenAndCloseMash) {
|
| + if (Shell::GetAshConfig() != Config::MASH)
|
| + return;
|
| +
|
| + // ShelfModel only has an APP_LIST item.
|
| + EXPECT_EQ(1, model_->item_count());
|
| +
|
| + // Windows with no valid ShelfItemType and ShelfID properties get shelf items.
|
| + std::unique_ptr<views::Widget> widget1 =
|
| + CreateTestWidget(nullptr, kShellWindowId_DefaultContainer, gfx::Rect());
|
| + EXPECT_EQ(2, model_->item_count());
|
| + std::unique_ptr<views::Widget> widget2 =
|
| + CreateTestWidget(nullptr, kShellWindowId_DefaultContainer, gfx::Rect());
|
| + EXPECT_EQ(3, model_->item_count());
|
| +
|
| + // Each ShelfItem is removed when the associated window is destroyed.
|
| + widget1.reset();
|
| + EXPECT_EQ(2, model_->item_count());
|
| + widget2.reset();
|
| + EXPECT_EQ(1, model_->item_count());
|
| +
|
| + // Windows with WindowState::ignored_by_shelf set do not get shelf items.
|
| + widget1 =
|
| + CreateTestWidget(nullptr, kShellWindowId_DefaultContainer, gfx::Rect());
|
| + wm::GetWindowState(widget1->GetNativeWindow())->set_ignored_by_shelf(true);
|
| + // TODO(msw): Make the flag a window property and remove this workaround.
|
| + widget1->GetNativeWindow()->SetProperty(aura::client::kDrawAttentionKey,
|
| + true);
|
| + EXPECT_EQ(1, model_->item_count());
|
| +}
|
| +
|
| TEST_F(ShelfWindowWatcherTest, CreateAndRemoveShelfItemProperties) {
|
| // TODO: investigate failure in mash. http://crbug.com/695562.
|
| if (Shell::GetAshConfig() == Config::MASH)
|
| @@ -374,6 +407,36 @@ TEST_F(ShelfWindowWatcherTest, DontCreateShelfEntriesForChildWindows) {
|
| EXPECT_EQ(initial_item_count, model_->item_count());
|
| }
|
|
|
| +TEST_F(ShelfWindowWatcherTest, DontCreateShelfEntriesForTransientWindows) {
|
| + const int initial_item_count = model_->item_count();
|
| +
|
| + std::unique_ptr<aura::Window> window(base::MakeUnique<aura::Window>(
|
| + nullptr, aura::client::WINDOW_TYPE_NORMAL));
|
| + window->Init(ui::LAYER_NOT_DRAWN);
|
| + window->SetProperty(kShelfIDKey, new std::string(ShelfID("foo").Serialize()));
|
| + window->SetProperty(kShelfItemTypeKey, static_cast<int32_t>(TYPE_APP));
|
| + Shell::GetPrimaryRootWindow()
|
| + ->GetChildById(kShellWindowId_DefaultContainer)
|
| + ->AddChild(window.get());
|
| + window->Show();
|
| + EXPECT_EQ(initial_item_count + 1, model_->item_count());
|
| +
|
| + std::unique_ptr<aura::Window> transient_window(base::MakeUnique<aura::Window>(
|
| + nullptr, aura::client::WINDOW_TYPE_NORMAL));
|
| + transient_window->Init(ui::LAYER_NOT_DRAWN);
|
| + transient_window->SetProperty(kShelfItemTypeKey,
|
| + static_cast<int32_t>(TYPE_APP));
|
| + ::wm::TransientWindowController::Get()->AddTransientChild(
|
| + window.get(), transient_window.get());
|
| + transient_window->Show();
|
| + // |transient_window| should not result in adding a new entry.
|
| + EXPECT_EQ(initial_item_count + 1, model_->item_count());
|
| +
|
| + transient_window.reset();
|
| + window.reset();
|
| + EXPECT_EQ(initial_item_count, model_->item_count());
|
| +}
|
| +
|
| // Ensures ShelfWindowWatcher supports windows opened prior to session start.
|
| using ShelfWindowWatcherSessionStartTest = test::NoSessionAshTestBase;
|
| TEST_F(ShelfWindowWatcherSessionStartTest, PreExistingWindow) {
|
|
|