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_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/test/base/in_process_browser_test.h" | 13 #include "chrome/test/base/in_process_browser_test.h" |
14 #include "chrome/test/base/ui_test_utils.h" | 14 #include "chrome/test/base/ui_test_utils.h" |
15 #include "content/public/browser/notification_details.h" | 15 #include "content/public/browser/notification_details.h" |
16 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
17 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
18 #include "content/public/browser/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
19 | 19 |
20 class ExtensionFromWebAppTest | 20 class ExtensionFromWebAppTest |
21 : public InProcessBrowserTest, public content::NotificationObserver { | 21 : public InProcessBrowserTest, public content::NotificationObserver { |
22 protected: | 22 protected: |
23 ExtensionFromWebAppTest() : installed_extension_(NULL) { | 23 ExtensionFromWebAppTest() : installed_extension_(NULL) { |
24 } | 24 } |
25 | 25 |
26 std::string expected_extension_id_; | 26 std::string expected_extension_id_; |
27 const Extension* installed_extension_; | 27 const extensions::Extension* installed_extension_; |
28 | 28 |
29 private: | 29 private: |
30 // InProcessBrowserTest | 30 // InProcessBrowserTest |
31 virtual void SetUpCommandLine(CommandLine* command_line) { | 31 virtual void SetUpCommandLine(CommandLine* command_line) { |
32 command_line->AppendSwitch(switches::kEnableCrxlessWebApps); | 32 command_line->AppendSwitch(switches::kEnableCrxlessWebApps); |
33 } | 33 } |
34 | 34 |
35 // content::NotificationObserver | 35 // content::NotificationObserver |
36 virtual void Observe(int type, | 36 virtual void Observe(int type, |
37 const content::NotificationSource& source, | 37 const content::NotificationSource& source, |
38 const content::NotificationDetails& details) { | 38 const content::NotificationDetails& details) { |
39 if (type == chrome::NOTIFICATION_EXTENSION_INSTALLED) { | 39 if (type == chrome::NOTIFICATION_EXTENSION_INSTALLED) { |
40 const Extension* extension = | 40 const extensions::Extension* extension = |
41 content::Details<const Extension>(details).ptr(); | 41 content::Details<const extensions::Extension>(details).ptr(); |
42 if (extension->id() == expected_extension_id_) { | 42 if (extension->id() == expected_extension_id_) { |
43 installed_extension_ = extension; | 43 installed_extension_ = extension; |
44 MessageLoopForUI::current()->Quit(); | 44 MessageLoopForUI::current()->Quit(); |
45 } | 45 } |
46 } | 46 } |
47 } | 47 } |
48 }; | 48 }; |
49 | 49 |
50 IN_PROC_BROWSER_TEST_F(ExtensionFromWebAppTest, Basic) { | 50 IN_PROC_BROWSER_TEST_F(ExtensionFromWebAppTest, Basic) { |
51 ASSERT_TRUE(test_server()->Start()); | 51 ASSERT_TRUE(test_server()->Start()); |
(...skipping 27 matching lines...) Expand all Loading... |
79 ExtensionAPIPermission::kNotification)); | 79 ExtensionAPIPermission::kNotification)); |
80 | 80 |
81 ASSERT_EQ(3u, installed_extension_->icons().map().size()); | 81 ASSERT_EQ(3u, installed_extension_->icons().map().size()); |
82 EXPECT_EQ("icons/16.png", installed_extension_->icons().Get( | 82 EXPECT_EQ("icons/16.png", installed_extension_->icons().Get( |
83 16, ExtensionIconSet::MATCH_EXACTLY)); | 83 16, ExtensionIconSet::MATCH_EXACTLY)); |
84 EXPECT_EQ("icons/48.png", installed_extension_->icons().Get( | 84 EXPECT_EQ("icons/48.png", installed_extension_->icons().Get( |
85 48, ExtensionIconSet::MATCH_EXACTLY)); | 85 48, ExtensionIconSet::MATCH_EXACTLY)); |
86 EXPECT_EQ("icons/128.png", installed_extension_->icons().Get( | 86 EXPECT_EQ("icons/128.png", installed_extension_->icons().Get( |
87 128, ExtensionIconSet::MATCH_EXACTLY)); | 87 128, ExtensionIconSet::MATCH_EXACTLY)); |
88 } | 88 } |
OLD | NEW |