| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/extension_service.h" | 7 #include "chrome/browser/extensions/extension_service.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/common/chrome_notification_types.h" | 10 #include "chrome/common/chrome_notification_types.h" |
| 11 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
| 12 #include "chrome/common/extensions/extension.h" | 12 #include "chrome/common/extensions/extension.h" |
| 13 #include "chrome/common/extensions/permissions/permission_set.h" | 13 #include "chrome/common/extensions/permissions/permission_set.h" |
| 14 #include "chrome/test/base/in_process_browser_test.h" | 14 #include "chrome/test/base/in_process_browser_test.h" |
| 15 #include "chrome/test/base/ui_test_utils.h" | 15 #include "chrome/test/base/ui_test_utils.h" |
| 16 #include "content/public/browser/notification_details.h" | 16 #include "content/public/browser/notification_details.h" |
| 17 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
| 18 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
| 19 #include "content/public/browser/notification_service.h" | 19 #include "content/public/browser/notification_service.h" |
| 20 | 20 |
| 21 using extensions::APIPermission; | 21 namespace extensions { |
| 22 | 22 |
| 23 class ExtensionFromWebAppTest | 23 class ExtensionFromWebAppTest |
| 24 : public InProcessBrowserTest, public content::NotificationObserver { | 24 : public InProcessBrowserTest, public content::NotificationObserver { |
| 25 protected: | 25 protected: |
| 26 ExtensionFromWebAppTest() : installed_extension_(NULL) { | 26 ExtensionFromWebAppTest() : installed_extension_(NULL) { |
| 27 } | 27 } |
| 28 | 28 |
| 29 std::string expected_extension_id_; | 29 std::string expected_extension_id_; |
| 30 const extensions::Extension* installed_extension_; | 30 const Extension* installed_extension_; |
| 31 | 31 |
| 32 private: | 32 private: |
| 33 // InProcessBrowserTest | 33 // InProcessBrowserTest |
| 34 virtual void SetUpCommandLine(CommandLine* command_line) { | 34 virtual void SetUpCommandLine(CommandLine* command_line) { |
| 35 command_line->AppendSwitch(switches::kEnableCrxlessWebApps); | 35 command_line->AppendSwitch(switches::kEnableCrxlessWebApps); |
| 36 } | 36 } |
| 37 | 37 |
| 38 // content::NotificationObserver | 38 // content::NotificationObserver |
| 39 virtual void Observe(int type, | 39 virtual void Observe(int type, |
| 40 const content::NotificationSource& source, | 40 const content::NotificationSource& source, |
| 41 const content::NotificationDetails& details) { | 41 const content::NotificationDetails& details) { |
| 42 if (type == chrome::NOTIFICATION_EXTENSION_INSTALLED) { | 42 if (type == chrome::NOTIFICATION_EXTENSION_INSTALLED) { |
| 43 const extensions::Extension* extension = | 43 const Extension* extension = |
| 44 content::Details<const extensions::Extension>(details).ptr(); | 44 content::Details<const Extension>(details).ptr(); |
| 45 if (extension->id() == expected_extension_id_) { | 45 if (extension->id() == expected_extension_id_) { |
| 46 installed_extension_ = extension; | 46 installed_extension_ = extension; |
| 47 MessageLoopForUI::current()->Quit(); | 47 MessageLoopForUI::current()->Quit(); |
| 48 } | 48 } |
| 49 } | 49 } |
| 50 } | 50 } |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 IN_PROC_BROWSER_TEST_F(ExtensionFromWebAppTest, Basic) { | 53 IN_PROC_BROWSER_TEST_F(ExtensionFromWebAppTest, Basic) { |
| 54 ASSERT_TRUE(test_server()->Start()); | 54 ASSERT_TRUE(test_server()->Start()); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 82 APIPermission::kNotification)); | 82 APIPermission::kNotification)); |
| 83 | 83 |
| 84 ASSERT_EQ(3u, installed_extension_->icons().map().size()); | 84 ASSERT_EQ(3u, installed_extension_->icons().map().size()); |
| 85 EXPECT_EQ("icons/16.png", installed_extension_->icons().Get( | 85 EXPECT_EQ("icons/16.png", installed_extension_->icons().Get( |
| 86 16, ExtensionIconSet::MATCH_EXACTLY)); | 86 16, ExtensionIconSet::MATCH_EXACTLY)); |
| 87 EXPECT_EQ("icons/48.png", installed_extension_->icons().Get( | 87 EXPECT_EQ("icons/48.png", installed_extension_->icons().Get( |
| 88 48, ExtensionIconSet::MATCH_EXACTLY)); | 88 48, ExtensionIconSet::MATCH_EXACTLY)); |
| 89 EXPECT_EQ("icons/128.png", installed_extension_->icons().Get( | 89 EXPECT_EQ("icons/128.png", installed_extension_->icons().Get( |
| 90 128, ExtensionIconSet::MATCH_EXACTLY)); | 90 128, ExtensionIconSet::MATCH_EXACTLY)); |
| 91 } | 91 } |
| 92 |
| 93 } // namespace extensions |
| OLD | NEW |