OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
11 #include "chrome/common/extensions/extension.h" | 11 #include "chrome/common/extensions/extension.h" |
12 #include "chrome/test/in_process_browser_test.h" | 12 #include "chrome/test/in_process_browser_test.h" |
| 13 #include "chrome/common/chrome_notification_types.h" |
13 #include "chrome/test/ui_test_utils.h" | 14 #include "chrome/test/ui_test_utils.h" |
14 #include "content/common/notification_details.h" | 15 #include "content/common/notification_details.h" |
15 #include "content/common/notification_observer.h" | 16 #include "content/common/notification_observer.h" |
16 #include "content/common/notification_registrar.h" | 17 #include "content/common/notification_registrar.h" |
17 #include "content/common/notification_type.h" | |
18 | 18 |
19 class ExtensionFromWebAppTest | 19 class ExtensionFromWebAppTest |
20 : public InProcessBrowserTest, public NotificationObserver { | 20 : public InProcessBrowserTest, public NotificationObserver { |
21 protected: | 21 protected: |
22 ExtensionFromWebAppTest() : installed_extension_(NULL) { | 22 ExtensionFromWebAppTest() : installed_extension_(NULL) { |
23 } | 23 } |
24 | 24 |
25 std::string expected_extension_id_; | 25 std::string expected_extension_id_; |
26 const Extension* installed_extension_; | 26 const Extension* installed_extension_; |
27 | 27 |
28 private: | 28 private: |
29 // InProcessBrowserTest | 29 // InProcessBrowserTest |
30 virtual void SetUpCommandLine(CommandLine* command_line) { | 30 virtual void SetUpCommandLine(CommandLine* command_line) { |
31 command_line->AppendSwitch(switches::kEnableCrxlessWebApps); | 31 command_line->AppendSwitch(switches::kEnableCrxlessWebApps); |
32 } | 32 } |
33 | 33 |
34 // NotificationObserver | 34 // NotificationObserver |
35 virtual void Observe(NotificationType type, | 35 virtual void Observe(int type, |
36 const NotificationSource& source, | 36 const NotificationSource& source, |
37 const NotificationDetails& details) { | 37 const NotificationDetails& details) { |
38 if (type == NotificationType::EXTENSION_INSTALLED) { | 38 if (type == chrome::NOTIFICATION_EXTENSION_INSTALLED) { |
39 const Extension* extension = Details<const Extension>(details).ptr(); | 39 const Extension* extension = Details<const Extension>(details).ptr(); |
40 if (extension->id() == expected_extension_id_) { | 40 if (extension->id() == expected_extension_id_) { |
41 installed_extension_ = extension; | 41 installed_extension_ = extension; |
42 MessageLoopForUI::current()->Quit(); | 42 MessageLoopForUI::current()->Quit(); |
43 } | 43 } |
44 } | 44 } |
45 } | 45 } |
46 }; | 46 }; |
47 | 47 |
48 IN_PROC_BROWSER_TEST_F(ExtensionFromWebAppTest, Basic) { | 48 IN_PROC_BROWSER_TEST_F(ExtensionFromWebAppTest, Basic) { |
49 ASSERT_TRUE(test_server()->Start()); | 49 ASSERT_TRUE(test_server()->Start()); |
50 browser()->profile()->GetExtensionService()->set_show_extensions_prompts( | 50 browser()->profile()->GetExtensionService()->set_show_extensions_prompts( |
51 false); | 51 false); |
52 | 52 |
53 NotificationRegistrar registrar; | 53 NotificationRegistrar registrar; |
54 registrar.Add(this, NotificationType::EXTENSION_INSTALLED, | 54 registrar.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED, |
55 NotificationService::AllSources()); | 55 NotificationService::AllSources()); |
56 | 56 |
57 expected_extension_id_ = "fnpgoaochgbdfjndakichfafiocjjpmm"; | 57 expected_extension_id_ = "fnpgoaochgbdfjndakichfafiocjjpmm"; |
58 ui_test_utils::NavigateToURL( | 58 ui_test_utils::NavigateToURL( |
59 browser(), | 59 browser(), |
60 test_server()->GetURL( | 60 test_server()->GetURL( |
61 "files/extensions/convert_web_app/application.html")); | 61 "files/extensions/convert_web_app/application.html")); |
62 | 62 |
63 if (!installed_extension_) | 63 if (!installed_extension_) |
64 ui_test_utils::RunMessageLoop(); | 64 ui_test_utils::RunMessageLoop(); |
(...skipping 12 matching lines...) Expand all Loading... |
77 ExtensionAPIPermission::kNotification)); | 77 ExtensionAPIPermission::kNotification)); |
78 | 78 |
79 ASSERT_EQ(3u, installed_extension_->icons().map().size()); | 79 ASSERT_EQ(3u, installed_extension_->icons().map().size()); |
80 EXPECT_EQ("icons/16.png", installed_extension_->icons().Get( | 80 EXPECT_EQ("icons/16.png", installed_extension_->icons().Get( |
81 16, ExtensionIconSet::MATCH_EXACTLY)); | 81 16, ExtensionIconSet::MATCH_EXACTLY)); |
82 EXPECT_EQ("icons/48.png", installed_extension_->icons().Get( | 82 EXPECT_EQ("icons/48.png", installed_extension_->icons().Get( |
83 48, ExtensionIconSet::MATCH_EXACTLY)); | 83 48, ExtensionIconSet::MATCH_EXACTLY)); |
84 EXPECT_EQ("icons/128.png", installed_extension_->icons().Get( | 84 EXPECT_EQ("icons/128.png", installed_extension_->icons().Get( |
85 128, ExtensionIconSet::MATCH_EXACTLY)); | 85 128, ExtensionIconSet::MATCH_EXACTLY)); |
86 } | 86 } |
OLD | NEW |