Chromium Code Reviews| 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 0b303c57e6b229748f7ce15328282235d2579a8b..d95a3e865160a01d4c30470cc1a38272bdb8e420 100644 |
| --- a/ash/shelf/shelf_window_watcher_unittest.cc |
| +++ b/ash/shelf/shelf_window_watcher_unittest.cc |
| @@ -18,11 +18,23 @@ |
| #include "ash/wm/window_state.h" |
| #include "ash/wm_window.h" |
| #include "base/strings/string_number_conversions.h" |
| +#include "third_party/skia/include/core/SkBitmap.h" |
| +#include "ui/aura/client/aura_constants.h" |
| #include "ui/aura/window.h" |
| #include "ui/base/hit_test.h" |
| +#include "ui/gfx/image/image_skia.h" |
| #include "ui/views/widget/widget.h" |
| namespace ash { |
| +namespace { |
| + |
| +// Create a test 1x1 icon image with a given |color|. |
| +gfx::ImageSkia CreateImageSkiaIcon(SkColor color) { |
| + SkBitmap bitmap; |
| + bitmap.allocN32Pixels(1, 1); |
| + bitmap.eraseColor(color); |
| + return gfx::ImageSkia::CreateFrom1xBitmap(bitmap); |
| +} |
| class ShelfWindowWatcherTest : public test::AshTestBase { |
| public: |
| @@ -302,6 +314,33 @@ TEST_F(ShelfWindowWatcherTest, PanelWindow) { |
| EXPECT_EQ(1, model_->item_count()); |
| } |
| +// Ensure items icons use the app icon and window icon aura::Window properties. |
| +TEST_F(ShelfWindowWatcherTest, ItemIcon) { |
| + // ShelfModel only has an APP_LIST item. |
| + EXPECT_EQ(1, model_->item_count()); |
| + |
| + // Create a ShelfItem for a window; it should have an empty icon. |
| + std::unique_ptr<views::Widget> widget = |
| + CreateTestWidget(nullptr, kShellWindowId_DefaultContainer, gfx::Rect()); |
| + aura::Window* window = widget->GetNativeWindow(); |
| + ShelfID id = CreateShelfItem(window); |
| + EXPECT_EQ(2, model_->item_count()); |
|
James Cook
2017/05/30 22:47:48
Was this supposed to look for an empty icon? If no
msw
2017/05/31 16:55:21
Done.
|
| + |
| + // Setting a window icon should update the item icon. |
| + const gfx::ImageSkia red = CreateImageSkiaIcon(SK_ColorRED); |
| + window->SetProperty(aura::client::kWindowIconKey, new gfx::ImageSkia(red)); |
| + EXPECT_EQ(SK_ColorRED, model_->items()[1].image.bitmap()->getColor(0, 0)); |
| + |
| + // Setting an app icon should override the window icon. |
| + const gfx::ImageSkia blue = CreateImageSkiaIcon(SK_ColorBLUE); |
| + window->SetProperty(aura::client::kAppIconKey, new gfx::ImageSkia(blue)); |
| + EXPECT_EQ(SK_ColorBLUE, model_->items()[1].image.bitmap()->getColor(0, 0)); |
| + |
| + // Clearing the app icon should restore the window icon to the shelf item. |
| + window->ClearProperty(aura::client::kAppIconKey); |
| + EXPECT_EQ(SK_ColorRED, model_->items()[1].image.bitmap()->getColor(0, 0)); |
| +} |
| + |
| TEST_F(ShelfWindowWatcherTest, DontCreateShelfEntriesForChildWindows) { |
| const int initial_item_count = model_->item_count(); |
| @@ -351,4 +390,5 @@ TEST_F(ShelfWindowWatcherSessionStartTest, PreExistingWindow) { |
| EXPECT_EQ(2, model->item_count()); |
| } |
| +} // namespace |
| } // namespace ash |