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

Unified Diff: chrome/browser/extensions/bookmark_app_helper_unittest.cc

Issue 266353006: Add generateAppForLink function in chrome.management (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 6 years, 7 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
« no previous file with comments | « chrome/browser/extensions/bookmark_app_helper.cc ('k') | chrome/common/extensions/api/_api_features.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/bookmark_app_helper_unittest.cc
===================================================================
--- chrome/browser/extensions/bookmark_app_helper_unittest.cc (revision 273767)
+++ chrome/browser/extensions/bookmark_app_helper_unittest.cc (working copy)
@@ -8,6 +8,9 @@
#include "chrome/browser/extensions/extension_service_unittest.h"
#include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
#include "chrome/test/base/testing_profile.h"
+#include "content/public/browser/render_process_host.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/test/web_contents_tester.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension_icon_set.h"
@@ -24,7 +27,9 @@
const char kAlternativeAppTitle[] = "Different test title";
const char kAppDescription[] = "Test description";
+const int kIconSizeTiny = extension_misc::EXTENSION_ICON_BITTY;
const int kIconSizeSmall = extension_misc::EXTENSION_ICON_SMALL;
+const int kIconSizeMedium = extension_misc::EXTENSION_ICON_MEDIUM;
const int kIconSizeLarge = extension_misc::EXTENSION_ICON_LARGE;
#endif
@@ -49,6 +54,19 @@
EXPECT_EQ(0u, service_->extensions()->size());
}
wjywbs 2014/05/30 14:43:03 Creating TestWebContents also creates a RenderProc
+ virtual void TearDown() OVERRIDE {
+ ExtensionServiceTestBase::TearDown();
+ for (content::RenderProcessHost::iterator i(
+ content::RenderProcessHost::AllHostsIterator());
+ !i.IsAtEnd();
+ i.Advance()) {
+ content::RenderProcessHost* host = i.GetCurrentValue();
+ if (Profile::FromBrowserContext(host->GetBrowserContext()) ==
+ profile_.get())
+ delete host;
+ }
+ }
+
private:
DISALLOW_COPY_AND_ASSIGN(BookmarkAppHelperExtensionServiceTest);
};
@@ -136,7 +154,9 @@
web_app_info.title = base::UTF8ToUTF16(kAppTitle);
web_app_info.description = base::UTF8ToUTF16(kAppDescription);
- TestBookmarkAppHelper helper(service_, web_app_info, NULL);
+ scoped_ptr<content::WebContents> contents(
+ content::WebContentsTester::CreateTestWebContents(profile_.get(), NULL));
+ TestBookmarkAppHelper helper(service_, web_app_info, contents.get());
helper.Create(base::Bind(&TestBookmarkAppHelper::CreationComplete,
base::Unretained(&helper)));
@@ -160,6 +180,47 @@
extension, kIconSizeSmall, ExtensionIconSet::MATCH_EXACTLY).empty());
}
+TEST_F(BookmarkAppHelperExtensionServiceTest, CreateBookmarkAppNoContents) {
+ WebApplicationInfo web_app_info;
+ web_app_info.app_url = GURL(kAppUrl);
+ web_app_info.title = base::UTF8ToUTF16(kAppTitle);
+ web_app_info.description = base::UTF8ToUTF16(kAppDescription);
+ web_app_info.icons.push_back(
+ CreateIconInfoWithBitmap(kIconSizeTiny, SK_ColorRED));
+
+ TestBookmarkAppHelper helper(service_, web_app_info, NULL);
+ helper.Create(base::Bind(&TestBookmarkAppHelper::CreationComplete,
+ base::Unretained(&helper)));
+
+ base::RunLoop().RunUntilIdle();
+ EXPECT_TRUE(helper.extension());
+ const Extension* extension =
+ service_->GetInstalledExtension(helper.extension()->id());
+ EXPECT_TRUE(extension);
+ EXPECT_EQ(1u, service_->extensions()->size());
+ EXPECT_TRUE(extension->from_bookmark());
+ EXPECT_EQ(kAppTitle, extension->name());
+ EXPECT_EQ(kAppDescription, extension->description());
+ EXPECT_EQ(GURL(kAppUrl), AppLaunchInfo::GetLaunchWebURL(extension));
+ EXPECT_FALSE(
+ IconsInfo::GetIconResource(
+ extension, kIconSizeTiny, ExtensionIconSet::MATCH_EXACTLY).empty());
+ EXPECT_FALSE(
+ IconsInfo::GetIconResource(
+ extension, kIconSizeSmall, ExtensionIconSet::MATCH_EXACTLY).empty());
+ EXPECT_FALSE(
+ IconsInfo::GetIconResource(extension,
+ kIconSizeSmall * 2,
+ ExtensionIconSet::MATCH_EXACTLY).empty());
+ EXPECT_FALSE(
+ IconsInfo::GetIconResource(
+ extension, kIconSizeMedium, ExtensionIconSet::MATCH_EXACTLY).empty());
+ EXPECT_FALSE(
+ IconsInfo::GetIconResource(extension,
+ kIconSizeMedium * 2,
+ ExtensionIconSet::MATCH_EXACTLY).empty());
+}
+
TEST_F(BookmarkAppHelperExtensionServiceTest, CreateAndUpdateBookmarkApp) {
EXPECT_EQ(0u, registry_->enabled_extensions().size());
WebApplicationInfo web_app_info;
« no previous file with comments | « chrome/browser/extensions/bookmark_app_helper.cc ('k') | chrome/common/extensions/api/_api_features.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698