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

Unified Diff: extensions/browser/app_window/app_window_browsertest.cc

Issue 2297633002: Add chrome.app.window API tests for items shown in shelf Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Pin and Restore Unit Test Created 4 years 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 | « chrome/test/data/extensions/platform_apps/app_window/generic/icon_128.png ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/app_window/app_window_browsertest.cc
diff --git a/extensions/browser/app_window/app_window_browsertest.cc b/extensions/browser/app_window/app_window_browsertest.cc
index 396c882e3d1d6630c8e3110337e562bc7649a91b..71f74542a4862100998f268ef3c06e1852d5ed97 100644
--- a/extensions/browser/app_window/app_window_browsertest.cc
+++ b/extensions/browser/app_window/app_window_browsertest.cc
@@ -5,6 +5,12 @@
#include "build/build_config.h"
#include "chrome/browser/apps/app_browsertest_util.h"
#include "extensions/browser/app_window/native_app_window.h"
+#include "extensions/browser/test_image_loader.h"
+#include "extensions/grit/extensions_browser_resources.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "ui/gfx/image/image_skia_operations.h"
+#include "ui/gfx/image/image_skia_source.h"
+#include "ui/gfx/skia_util.h"
namespace extensions {
@@ -66,6 +72,70 @@ IN_PROC_BROWSER_TEST_F(AppWindowBrowserTest, FrameInsetsForNoFrame) {
CloseAppWindow(app_window);
}
+// Verifies that a window created with showInShelf set to true is properly
+// enabled in AppWindow.
+IN_PROC_BROWSER_TEST_F(AppWindowBrowserTest,
+ ShowInShelfWindowWithWindowKeySet) {
+ AppWindow* app_window =
+ CreateTestAppWindow("{ \"id\": \"appwindow\", \"showInShelf\": true }");
+
+ ASSERT_TRUE(app_window);
+
+ // showInShelf must be true.
+ EXPECT_EQ(true, app_window->show_in_shelf());
+
+ CloseAppWindow(app_window);
+}
+
+// Verifies that a window created with showInShelf=true and an icon URL has
+// the icon properly set in AppWindow.
+IN_PROC_BROWSER_TEST_F(AppWindowBrowserTest, ShowInShelfWindowIcon) {
+ AppWindow* app_window = CreateTestAppWindow(
+ "{ \"id\": \"appwindow\", \"showInShelf\": true, "
+ "\"icon\":\"icon_128.png\" }");
+
+ ASSERT_TRUE(app_window);
+
+ // showInShelf must be true.
+ EXPECT_EQ(true, app_window->show_in_shelf());
+
+ // Check for local window icon URL.
+ EXPECT_EQ(
+ "chrome-extension://" + app_window->extension_id() + "/icon_128.png",
+ app_window->window_icon_url().spec());
+
+ // Get the window base image that is set using the icon URL property.
+ SkBitmap window_icon_bitmap = TestImageLoader::LoadAndGetExtensionBitmap(
+ app_window->GetExtension(), "icon_128.png", 128);
+ // Create the window icon using the window base image and the extension app
+ // icon badge.
+ gfx::Image window_icon_with_badge =
+ gfx::Image(gfx::ImageSkiaOperations::CreateIconWithBadge(
+ gfx::Image::CreateFrom1xBitmap(window_icon_bitmap).AsImageSkia(),
+ GetAppIconImage(app_window)));
+
+ // Check app icon and window icon not empty.
+ EXPECT_EQ(false, app_window->app_icon().IsEmpty());
+ EXPECT_EQ(false, window_icon_bitmap.empty());
+ EXPECT_EQ(false, window_icon_with_badge.IsEmpty());
+
+ // Check icons width.
+ EXPECT_EQ(128, app_window->app_icon().Width());
+ EXPECT_EQ(128, window_icon_bitmap.width());
+ EXPECT_EQ(128, window_icon_with_badge.Width());
+
+ // Check icons height.
+ EXPECT_EQ(128, app_window->app_icon().Height());
+ EXPECT_EQ(128, window_icon_bitmap.height());
+ EXPECT_EQ(128, window_icon_with_badge.Height());
+
+ // Check window icon is set properly.
+ EXPECT_EQ(true, gfx::BitmapsAreEqual(app_window->app_icon().AsBitmap(),
+ window_icon_with_badge.AsBitmap()));
+
+ CloseAppWindow(app_window);
+}
+
} // namespace
} // namespace extensions
« no previous file with comments | « chrome/test/data/extensions/platform_apps/app_window/generic/icon_128.png ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698