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 "base/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/extensions/autoupdate_interceptor.h" | 8 #include "chrome/browser/extensions/autoupdate_interceptor.h" |
9 #include "chrome/browser/extensions/extension_apitest.h" | 9 #include "chrome/browser/extensions/extension_apitest.h" |
10 #include "chrome/browser/extensions/extension_browsertest.h" | 10 #include "chrome/browser/extensions/extension_browsertest.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "content/public/browser/navigation_entry.h" | 30 #include "content/public/browser/navigation_entry.h" |
31 #include "content/public/browser/notification_service.h" | 31 #include "content/public/browser/notification_service.h" |
32 #include "net/base/net_util.h" | 32 #include "net/base/net_util.h" |
33 #include "net/test/test_server.h" | 33 #include "net/test/test_server.h" |
34 #include "webkit/glue/webpreferences.h" | 34 #include "webkit/glue/webpreferences.h" |
35 | 35 |
36 #if defined(TOOLKIT_VIEWS) | 36 #if defined(TOOLKIT_VIEWS) |
37 #include "chrome/browser/ui/views/frame/browser_view.h" | 37 #include "chrome/browser/ui/views/frame/browser_view.h" |
38 #endif | 38 #endif |
39 | 39 |
| 40 using content::NavigationController; |
40 using content::WebContents; | 41 using content::WebContents; |
41 | 42 |
42 const std::string kSubscribePage = "/subscribe.html"; | 43 const std::string kSubscribePage = "/subscribe.html"; |
43 const std::string kFeedPage = "files/feeds/feed.html"; | 44 const std::string kFeedPage = "files/feeds/feed.html"; |
44 const std::string kFeedPageMultiRel = "files/feeds/feed_multi_rel.html"; | 45 const std::string kFeedPageMultiRel = "files/feeds/feed_multi_rel.html"; |
45 const std::string kNoFeedPage = "files/feeds/no_feed.html"; | 46 const std::string kNoFeedPage = "files/feeds/no_feed.html"; |
46 const std::string kValidFeed0 = "files/feeds/feed_script.xml"; | 47 const std::string kValidFeed0 = "files/feeds/feed_script.xml"; |
47 const std::string kValidFeed1 = "files/feeds/feed1.xml"; | 48 const std::string kValidFeed1 = "files/feeds/feed1.xml"; |
48 const std::string kValidFeed2 = "files/feeds/feed2.xml"; | 49 const std::string kValidFeed2 = "files/feeds/feed2.xml"; |
49 const std::string kValidFeed3 = "files/feeds/feed3.xml"; | 50 const std::string kValidFeed3 = "files/feeds/feed3.xml"; |
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 ASSERT_TRUE(extension); | 806 ASSERT_TRUE(extension); |
806 EXPECT_EQ(size_before + 1, service->extensions()->size()); | 807 EXPECT_EQ(size_before + 1, service->extensions()->size()); |
807 // Now the plugin should be in the cache, but we have to reload the page for | 808 // Now the plugin should be in the cache, but we have to reload the page for |
808 // it to work. | 809 // it to work. |
809 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 810 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
810 tab->GetRenderViewHost(), L"", L"testPluginWorks()", &result)); | 811 tab->GetRenderViewHost(), L"", L"testPluginWorks()", &result)); |
811 EXPECT_FALSE(result); | 812 EXPECT_FALSE(result); |
812 { | 813 { |
813 ui_test_utils::WindowedNotificationObserver observer( | 814 ui_test_utils::WindowedNotificationObserver observer( |
814 content::NOTIFICATION_LOAD_STOP, | 815 content::NOTIFICATION_LOAD_STOP, |
815 content::Source<content::NavigationController>( | 816 content::Source<NavigationController>( |
816 &browser()->GetSelectedTabContentsWrapper()->tab_contents()-> | 817 &browser()->GetSelectedTabContentsWrapper()->tab_contents()-> |
817 GetController())); | 818 GetController())); |
818 browser()->Reload(CURRENT_TAB); | 819 browser()->Reload(CURRENT_TAB); |
819 observer.Wait(); | 820 observer.Wait(); |
820 } | 821 } |
821 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 822 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
822 tab->GetRenderViewHost(), L"", L"testPluginWorks()", &result)); | 823 tab->GetRenderViewHost(), L"", L"testPluginWorks()", &result)); |
823 EXPECT_TRUE(result); | 824 EXPECT_TRUE(result); |
824 | 825 |
825 EXPECT_EQ(size_before + 1, service->extensions()->size()); | 826 EXPECT_EQ(size_before + 1, service->extensions()->size()); |
826 UnloadExtension(extension->id()); | 827 UnloadExtension(extension->id()); |
827 EXPECT_EQ(size_before, service->extensions()->size()); | 828 EXPECT_EQ(size_before, service->extensions()->size()); |
828 | 829 |
829 // Now the plugin should be unloaded, and the page should be broken. | 830 // Now the plugin should be unloaded, and the page should be broken. |
830 | 831 |
831 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 832 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
832 tab->GetRenderViewHost(), L"", L"testPluginWorks()", &result)); | 833 tab->GetRenderViewHost(), L"", L"testPluginWorks()", &result)); |
833 EXPECT_FALSE(result); | 834 EXPECT_FALSE(result); |
834 | 835 |
835 // If we reload the extension and page, it should work again. | 836 // If we reload the extension and page, it should work again. |
836 | 837 |
837 ASSERT_TRUE(LoadExtension(extension_dir)); | 838 ASSERT_TRUE(LoadExtension(extension_dir)); |
838 EXPECT_EQ(size_before + 1, service->extensions()->size()); | 839 EXPECT_EQ(size_before + 1, service->extensions()->size()); |
839 { | 840 { |
840 ui_test_utils::WindowedNotificationObserver observer( | 841 ui_test_utils::WindowedNotificationObserver observer( |
841 content::NOTIFICATION_LOAD_STOP, | 842 content::NOTIFICATION_LOAD_STOP, |
842 content::Source<content::NavigationController>( | 843 content::Source<NavigationController>( |
843 &browser()->GetSelectedTabContentsWrapper()->tab_contents()-> | 844 &browser()->GetSelectedTabContentsWrapper()->tab_contents()-> |
844 GetController())); | 845 GetController())); |
845 browser()->Reload(CURRENT_TAB); | 846 browser()->Reload(CURRENT_TAB); |
846 observer.Wait(); | 847 observer.Wait(); |
847 } | 848 } |
848 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 849 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
849 tab->GetRenderViewHost(), L"", L"testPluginWorks()", &result)); | 850 tab->GetRenderViewHost(), L"", L"testPluginWorks()", &result)); |
850 EXPECT_TRUE(result); | 851 EXPECT_TRUE(result); |
851 } | 852 } |
852 | 853 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 | 931 |
931 EXPECT_EQ(extension->GetResourceURL("options.html"), | 932 EXPECT_EQ(extension->GetResourceURL("options.html"), |
932 tab_strip->GetTabContentsAt(1)->tab_contents()->GetURL()); | 933 tab_strip->GetTabContentsAt(1)->tab_contents()->GetURL()); |
933 } | 934 } |
934 | 935 |
935 //============================================================================== | 936 //============================================================================== |
936 // STOP! Please do not add any more random-ass tests here. Create new files for | 937 // STOP! Please do not add any more random-ass tests here. Create new files for |
937 // your tests grouped by functionality. Also, you should strongly consider using | 938 // your tests grouped by functionality. Also, you should strongly consider using |
938 // ExtensionAPITest if possible. | 939 // ExtensionAPITest if possible. |
939 //============================================================================== | 940 //============================================================================== |
OLD | NEW |