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

Unified Diff: ui/views/mus/native_widget_mus_unittest.cc

Issue 2519583002: Add gfx::ImageSkia and icon support to aura::PropertyConverter. (Closed)
Patch Set: Fix ConvertPropertyForTransport; add unit test. Created 4 years, 1 month 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
« no previous file with comments | « ui/views/mus/native_widget_mus.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/mus/native_widget_mus_unittest.cc
diff --git a/ui/views/mus/native_widget_mus_unittest.cc b/ui/views/mus/native_widget_mus_unittest.cc
index d670342b3aa56d9595a4e82e7a4bcdab5453be58..86beee68a63d961119300c5d3b696273e171eb85 100644
--- a/ui/views/mus/native_widget_mus_unittest.cc
+++ b/ui/views/mus/native_widget_mus_unittest.cc
@@ -103,23 +103,31 @@ class WidgetActivationObserver : public WidgetObserver {
DISALLOW_COPY_AND_ASSIGN(WidgetActivationObserver);
};
-// A WidgetDelegate that supplies an app icon.
+// A WidgetDelegate that supplies app and window icons.
class TestWidgetDelegate : public WidgetDelegateView {
public:
- explicit TestWidgetDelegate(const SkBitmap& icon)
- : app_icon_(gfx::ImageSkia::CreateFrom1xBitmap(icon)) {}
+ explicit TestWidgetDelegate(const SkBitmap& app_icon,
+ const SkBitmap& window_icon)
+ : app_icon_(gfx::ImageSkia::CreateFrom1xBitmap(app_icon)),
+ window_icon_(gfx::ImageSkia::CreateFrom1xBitmap(window_icon)) {}
~TestWidgetDelegate() override {}
- void SetIcon(const SkBitmap& icon) {
+ void SetAppIcon(const SkBitmap& icon) {
app_icon_ = gfx::ImageSkia::CreateFrom1xBitmap(icon);
}
+ void SetWindowIcon(const SkBitmap& icon) {
+ window_icon_ = gfx::ImageSkia::CreateFrom1xBitmap(icon);
+ }
+
// views::WidgetDelegate:
gfx::ImageSkia GetWindowAppIcon() override { return app_icon_; }
+ gfx::ImageSkia GetWindowIcon() override { return window_icon_; }
private:
gfx::ImageSkia app_icon_;
+ gfx::ImageSkia window_icon_;
DISALLOW_COPY_AND_ASSIGN(TestWidgetDelegate);
};
@@ -248,57 +256,67 @@ TEST_F(NativeWidgetMusTest, ShowNonActivatableWidget) {
EXPECT_EQ(0u, activation_observer.changes().size());
}
-// Tests that a window with an icon sets the ui::Window icon property.
-TEST_F(NativeWidgetMusTest, AppIcon) {
- // Create a Widget with a bitmap as the icon.
- SkBitmap source_bitmap = MakeBitmap(SK_ColorRED);
+// Tests that a window with app/window icons sets ui::Window icon properties.
+TEST_F(NativeWidgetMusTest, AppAndWindowIcons) {
+ // Create a Widget with app and window icons.
+ SkBitmap app_icon_input = MakeBitmap(SK_ColorRED);
+ SkBitmap window_icon_input = MakeBitmap(SK_ColorGREEN);
std::unique_ptr<Widget> widget(
- CreateWidget(new TestWidgetDelegate(source_bitmap)));
+ CreateWidget(new TestWidgetDelegate(app_icon_input, window_icon_input)));
- // The ui::Window has the icon property.
+ // The ui::Window has the expected icon properties.
ui::Window* window =
static_cast<NativeWidgetMus*>(widget->native_widget_private())->window();
+ EXPECT_TRUE(
+ window->HasSharedProperty(ui::mojom::WindowManager::kAppIcon_Property));
EXPECT_TRUE(window->HasSharedProperty(
- ui::mojom::WindowManager::kWindowAppIcon_Property));
-
- // The icon is the expected icon.
- SkBitmap icon = window->GetSharedProperty<SkBitmap>(
- ui::mojom::WindowManager::kWindowAppIcon_Property);
- EXPECT_TRUE(gfx::BitmapsAreEqual(source_bitmap, icon));
+ ui::mojom::WindowManager::kWindowIcon_Property));
+ SkBitmap app_icon = window->GetSharedProperty<SkBitmap>(
+ ui::mojom::WindowManager::kAppIcon_Property);
+ EXPECT_TRUE(gfx::BitmapsAreEqual(app_icon_input, app_icon));
+ SkBitmap window_icon = window->GetSharedProperty<SkBitmap>(
+ ui::mojom::WindowManager::kWindowIcon_Property);
+ EXPECT_TRUE(gfx::BitmapsAreEqual(window_icon_input, window_icon));
}
-// Tests that a window without an icon does not set the ui::Window icon
-// property.
-TEST_F(NativeWidgetMusTest, NoAppIcon) {
- // Create a Widget without a special icon.
+// Tests that a window without icons does not set ui::Window icon properties.
+TEST_F(NativeWidgetMusTest, NoAppNorWindowIcon) {
+ // Create a Widget without app or window icons, by supplying a null delegate.
std::unique_ptr<Widget> widget(CreateWidget(nullptr));
- // The ui::Window does not have an icon property.
+ // The ui::Window does not have either icon property.
ui::Window* window =
static_cast<NativeWidgetMus*>(widget->native_widget_private())->window();
+ EXPECT_FALSE(
+ window->HasSharedProperty(ui::mojom::WindowManager::kAppIcon_Property));
EXPECT_FALSE(window->HasSharedProperty(
- ui::mojom::WindowManager::kWindowAppIcon_Property));
+ ui::mojom::WindowManager::kWindowIcon_Property));
}
-// Tests that changing the icon on a Widget updates the ui::Window icon
-// property.
-TEST_F(NativeWidgetMusTest, ChangeAppIcon) {
- // Create a Widget with an icon.
+// Tests that changing icons on a Widget updates ui::Window icon properties.
+TEST_F(NativeWidgetMusTest, ChangeAppAndWindowIcons) {
+ // Create a Widget with app and window icons.
SkBitmap bitmap1 = MakeBitmap(SK_ColorRED);
- TestWidgetDelegate* delegate = new TestWidgetDelegate(bitmap1);
+ TestWidgetDelegate* delegate = new TestWidgetDelegate(bitmap1, bitmap1);
std::unique_ptr<Widget> widget(CreateWidget(delegate));
+ ui::Window* window =
+ static_cast<NativeWidgetMus*>(widget->native_widget_private())->window();
- // Update the icon to a new image.
+ // Update the app icon image; verify the window has the updated icon.
SkBitmap bitmap2 = MakeBitmap(SK_ColorGREEN);
- delegate->SetIcon(bitmap2);
+ delegate->SetAppIcon(bitmap2);
widget->UpdateWindowIcon();
+ SkBitmap app_icon = window->GetSharedProperty<SkBitmap>(
+ ui::mojom::WindowManager::kAppIcon_Property);
+ EXPECT_TRUE(gfx::BitmapsAreEqual(bitmap2, app_icon));
- // The window has the updated icon.
- ui::Window* window =
- static_cast<NativeWidgetMus*>(widget->native_widget_private())->window();
- SkBitmap icon = window->GetSharedProperty<SkBitmap>(
- ui::mojom::WindowManager::kWindowAppIcon_Property);
- EXPECT_TRUE(gfx::BitmapsAreEqual(bitmap2, icon));
+ // Update the window icon image; verify the window has the updated icon.
+ SkBitmap bitmap3 = MakeBitmap(SK_ColorBLUE);
+ delegate->SetWindowIcon(bitmap3);
+ widget->UpdateWindowIcon();
+ SkBitmap window_icon = window->GetSharedProperty<SkBitmap>(
+ ui::mojom::WindowManager::kWindowIcon_Property);
+ EXPECT_TRUE(gfx::BitmapsAreEqual(bitmap3, window_icon));
}
TEST_F(NativeWidgetMusTest, ValidLayerTree) {
« no previous file with comments | « ui/views/mus/native_widget_mus.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698