Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3421)

Unified Diff: ash/common/shelf/shelf_window_watcher_unittest.cc

Issue 2357143004: mash: Support ShelfWindowWatcher via ShelfItem properties. (Closed)
Patch Set: Set Settings WmWindow title with a WmWindowObserver. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ash/common/shelf/shelf_window_watcher_unittest.cc
diff --git a/ash/common/shelf/shelf_window_watcher_unittest.cc b/ash/common/shelf/shelf_window_watcher_unittest.cc
index 08413b65bb2b49a8170a3d2d9183180945bba8ed..24580c5d78eed0baa271ee7112a18c7d988a5c57 100644
--- a/ash/common/shelf/shelf_window_watcher_unittest.cc
+++ b/ash/common/shelf/shelf_window_watcher_unittest.cc
@@ -12,6 +12,7 @@
#include "ash/common/wm_lookup.h"
#include "ash/common/wm_shell.h"
#include "ash/common/wm_window.h"
+#include "ash/common/wm_window_property.h"
#include "ash/test/ash_test_base.h"
#include "ui/base/hit_test.h"
#include "ui/views/widget/widget.h"
@@ -35,9 +36,7 @@ class ShelfWindowWatcherTest : public test::AshTestBase {
ShelfID CreateShelfItem(WmWindow* window) {
ShelfID id = model_->next_id();
- ShelfItemDetails item_details;
- item_details.type = TYPE_PLATFORM_APP;
- window->SetShelfItemDetails(item_details);
+ window->SetIntProperty(WmWindowProperty::SHELF_ITEM_TYPE, TYPE_DIALOG);
James Cook 2016/09/28 20:41:03 This is fine, but just curious: does it need to ch
msw 2016/09/28 23:27:46 Nope! Just done to keep it a one-liner. Let me kno
James Cook 2016/09/29 02:49:46 This is fine.
return id;
}
@@ -53,7 +52,7 @@ TEST_F(ShelfWindowWatcherTest, OpenAndClose) {
// ShelfModel only has an APP_LIST item.
EXPECT_EQ(1, model_->item_count());
- // Adding windows with ShelfItemDetails properties adds shelf items.
+ // Adding windows with valid ShelfItemType properties adds shelf items.
James Cook 2016/09/28 20:41:03 Thanks for fixing all the comments.
msw 2016/09/28 23:27:46 Acknowledged.
std::unique_ptr<views::Widget> widget1 =
CreateTestWidget(nullptr, kShellWindowId_DefaultContainer, gfx::Rect());
CreateShelfItem(WmLookup::Get()->GetWindowForWidget(widget1.get()));
@@ -70,11 +69,11 @@ TEST_F(ShelfWindowWatcherTest, OpenAndClose) {
EXPECT_EQ(1, model_->item_count());
}
-TEST_F(ShelfWindowWatcherTest, CreateAndRemoveShelfItemDetails) {
+TEST_F(ShelfWindowWatcherTest, CreateAndRemoveShelfItemProperties) {
// ShelfModel only has an APP_LIST item.
EXPECT_EQ(1, model_->item_count());
- // Creating windows without ShelfItemDetails does not add items.
+ // Creating windows without a valid ShelfItemType does not add items.
std::unique_ptr<views::Widget> widget1 =
CreateTestWidget(nullptr, kShellWindowId_DefaultContainer, gfx::Rect());
WmWindow* window1 = WmLookup::Get()->GetWindowForWidget(widget1.get());
@@ -97,13 +96,13 @@ TEST_F(ShelfWindowWatcherTest, CreateAndRemoveShelfItemDetails) {
int index_w2 = model_->ItemIndexByID(id_w2);
EXPECT_EQ(STATUS_ACTIVE, model_->items()[index_w2].status);
- // ShelfItem is removed when its window property is cleared.
- window1->ClearShelfItemDetails();
+ // ShelfItem is removed when the item type window property is cleared.
+ window1->SetIntProperty(WmWindowProperty::SHELF_ITEM_TYPE, TYPE_UNDEFINED);
EXPECT_EQ(2, model_->item_count());
- window2->ClearShelfItemDetails();
+ window2->SetIntProperty(WmWindowProperty::SHELF_ITEM_TYPE, TYPE_UNDEFINED);
EXPECT_EQ(1, model_->item_count());
// Clearing twice doesn't do anything.
- window2->ClearShelfItemDetails();
+ window2->SetIntProperty(WmWindowProperty::SHELF_ITEM_TYPE, TYPE_UNDEFINED);
James Cook 2016/09/28 20:41:03 How about adding a test that sets an icon ID but n
msw 2016/09/28 23:27:46 Done.
EXPECT_EQ(1, model_->item_count());
}
@@ -156,11 +155,8 @@ TEST_F(ShelfWindowWatcherTest, UpdateWindowProperty) {
int index = model_->ItemIndexByID(id);
EXPECT_EQ(STATUS_ACTIVE, model_->items()[index].status);
- // Update ShelfItem for |window|.
- ShelfItemDetails details;
- details.type = TYPE_PLATFORM_APP;
-
- window->SetShelfItemDetails(details);
+ // Update the ShelfItemType for |window|.
+ window->SetIntProperty(WmWindowProperty::SHELF_ITEM_TYPE, TYPE_PLATFORM_APP);
// No new item is created after updating a launcher item.
EXPECT_EQ(2, model_->item_count());
// index and id are not changed after updating a launcher item.

Powered by Google App Engine
This is Rietveld 408576698