Update broken references to image assets
[chromium-blink-merge.git] / chrome / browser / extensions / convert_web_app_browsertest.cc
blob5210ca0f1e96850d9ff429bf1028c45b17845280
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include <string>
7 #include "base/command_line.h"
8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/tabs/tab_strip_model.h"
12 #include "chrome/common/chrome_switches.h"
13 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
14 #include "chrome/test/base/in_process_browser_test.h"
15 #include "chrome/test/base/test_switches.h"
16 #include "chrome/test/base/ui_test_utils.h"
17 #include "content/public/browser/notification_details.h"
18 #include "content/public/browser/notification_observer.h"
19 #include "content/public/browser/notification_registrar.h"
20 #include "content/public/browser/notification_service.h"
21 #include "content/public/browser/web_contents.h"
22 #include "content/public/test/browser_test_utils.h"
23 #include "extensions/browser/extension_system.h"
24 #include "extensions/browser/notification_types.h"
25 #include "extensions/common/extension.h"
26 #include "extensions/common/extension_icon_set.h"
27 #include "extensions/common/manifest_handlers/icons_handler.h"
28 #include "extensions/common/permissions/permission_set.h"
29 #include "extensions/common/permissions/permissions_data.h"
31 namespace extensions {
33 class ExtensionFromWebAppTest
34 : public InProcessBrowserTest, public content::NotificationObserver {
35 protected:
36 ExtensionFromWebAppTest() : installed_extension_(NULL) {
39 std::string expected_extension_id_;
40 const Extension* installed_extension_;
42 private:
43 // content::NotificationObserver
44 void Observe(int type,
45 const content::NotificationSource& source,
46 const content::NotificationDetails& details) override {
47 if (type ==
48 extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED) {
49 const Extension* extension =
50 content::Details<const InstalledExtensionInfo>(details)->extension;
51 if (extension->id() == expected_extension_id_) {
52 installed_extension_ = extension;
53 base::MessageLoopForUI::current()->Quit();
59 // TODO(samarth): delete along with rest of the NTP4 code.
60 IN_PROC_BROWSER_TEST_F(ExtensionFromWebAppTest, DISABLED_Basic) {
61 #if defined(OS_WIN) && defined(USE_ASH)
62 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
63 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
64 switches::kAshBrowserTests))
65 return;
66 #endif
68 ExtensionService* service =
69 ExtensionSystem::Get(browser()->profile())->extension_service();
70 service->set_show_extensions_prompts(false);
72 content::NotificationRegistrar registrar;
73 registrar.Add(this,
74 extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED,
75 content::NotificationService::AllSources());
77 expected_extension_id_ = "ffnmbohohhobhkjpfbefbjifapgcmpaa";
78 ui_test_utils::NavigateToURL(
79 browser(),
80 GURL("chrome://newtab"));
81 EXPECT_TRUE(content::ExecuteScript(
82 browser()->tab_strip_model()->GetActiveWebContents(),
83 "chrome.send('generateAppForLink', "
84 "['http://www.example.com', 'Test application', 0])"));
86 if (!installed_extension_)
87 content::RunMessageLoop();
89 EXPECT_TRUE(installed_extension_);
90 EXPECT_TRUE(installed_extension_->is_hosted_app());
91 EXPECT_EQ("Test application", installed_extension_->name());
92 EXPECT_EQ("", installed_extension_->description());
93 EXPECT_EQ(GURL("http://www.example.com/"),
94 AppLaunchInfo::GetLaunchWebURL(installed_extension_));
95 EXPECT_EQ(LAUNCH_CONTAINER_TAB,
96 AppLaunchInfo::GetLaunchContainer(installed_extension_));
97 EXPECT_EQ(0u,
98 installed_extension_->permissions_data()
99 ->active_permissions()
100 ->apis()
101 .size());
102 EXPECT_EQ(0u, IconsInfo::GetIcons(installed_extension_).map().size());
105 } // namespace extensions