Chromium Code Reviews| 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 <deque> | 5 #include <deque> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "chrome/browser/prerender/prerender_contents.h" | 10 #include "chrome/browser/prerender/prerender_contents.h" |
| (...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 706 return; | 706 return; |
| 707 } | 707 } |
| 708 | 708 |
| 709 // Show the task manager. This populates the model. | 709 // Show the task manager. This populates the model. |
| 710 browser()->window()->ShowTaskManager(); | 710 browser()->window()->ShowTaskManager(); |
| 711 | 711 |
| 712 // Start with two resources. | 712 // Start with two resources. |
| 713 EXPECT_EQ(2, model()->ResourceCount()); | 713 EXPECT_EQ(2, model()->ResourceCount()); |
| 714 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); | 714 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); |
| 715 | 715 |
| 716 // The prerender makes three. | 716 // The prerender makes three but we may have another Tab that we haven't |
| 717 EXPECT_EQ(3, model()->ResourceCount()); | 717 // deleted yet. |
| 718 EXPECT_GE(model()->ResourceCount(), 3); | |
|
mmenke
2011/05/06 16:08:09
Shouldn't we always have 4 here? Browser, old (st
| |
| 719 EXPECT_LE(model()->ResourceCount(), 4); | |
| 718 | 720 |
| 719 // It should have a TabContents associated with it. | 721 // One of the resources that has a TabContents associated with it should have |
| 720 ASSERT_TRUE(model()->GetResourceTabContents(1) != NULL); | 722 // the Prerender prefix. |
| 721 | 723 const string16 prefix = |
| 722 // The prefix should be "Prerender:" | |
| 723 string16 prefix = | |
| 724 l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_PRERENDER_PREFIX, | 724 l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_PRERENDER_PREFIX, |
| 725 string16()); | 725 string16()); |
| 726 ASSERT_TRUE(StartsWith(model()->GetResourceTitle(2), prefix, true)); | 726 int num_prerender_tabs = 0; |
| 727 for (int i = 0; i < model()->ResourceCount(); ++i) { | |
| 728 if (model()->GetResourceTabContents(i) && | |
| 729 StartsWith(model()->GetResourceTitle(i), prefix, true)) { | |
| 730 ++num_prerender_tabs; | |
| 731 } | |
| 732 } | |
| 733 ASSERT_EQ(1, num_prerender_tabs); | |
| 727 | 734 |
| 728 NavigateToDestURL(); | 735 NavigateToDestURL(); |
| 729 | 736 |
| 730 // Prerender task should become a normal tab. | 737 // Prerender task should become a normal tab but we still may not have deleted |
| 731 EXPECT_EQ(3, model()->ResourceCount()); | 738 // the old one. |
| 739 EXPECT_GE(model()->ResourceCount(), 3); | |
| 740 EXPECT_LE(model()->ResourceCount(), 4); | |
| 732 | 741 |
| 733 // It should have a TabContents associated with it. | 742 // There should be no Tabs with the Prerender prefix. |
| 734 ASSERT_TRUE(model()->GetResourceTabContents(2) != NULL); | 743 num_prerender_tabs = 0; |
| 735 | 744 for (int i = 0; i < model()->ResourceCount(); ++i) { |
| 736 // The prefix should now be "Tab:" | 745 if (model()->GetResourceTabContents(i) && |
| 737 prefix = l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_TAB_PREFIX, | 746 StartsWith(model()->GetResourceTitle(i), prefix, true)) { |
| 738 string16()); | 747 ++num_prerender_tabs; |
| 739 ASSERT_TRUE(StartsWith(model()->GetResourceTitle(2), prefix, true)); | 748 } |
| 749 } | |
| 750 ASSERT_EQ(0, num_prerender_tabs); | |
| 740 } | 751 } |
| 741 | 752 |
| 742 // Checks that prerenderers will terminate when an audio tag is encountered. | 753 // Checks that prerenderers will terminate when an audio tag is encountered. |
| 743 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderHTML5Audio) { | 754 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderHTML5Audio) { |
| 744 PrerenderTestURL("files/prerender/prerender_html5_audio.html", | 755 PrerenderTestURL("files/prerender/prerender_html5_audio.html", |
| 745 FINAL_STATUS_HTML5_MEDIA, | 756 FINAL_STATUS_HTML5_MEDIA, |
| 746 1); | 757 1); |
| 747 } | 758 } |
| 748 | 759 |
| 749 // Checks that prerenderers will terminate when a video tag is encountered. | 760 // Checks that prerenderers will terminate when a video tag is encountered. |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 918 std::string replacement_path; | 929 std::string replacement_path; |
| 919 ASSERT_TRUE(net::TestServer::GetFilePathWithReplacements( | 930 ASSERT_TRUE(net::TestServer::GetFilePathWithReplacements( |
| 920 "files/prerender/prerender_with_image.html", | 931 "files/prerender/prerender_with_image.html", |
| 921 replacement_text, | 932 replacement_text, |
| 922 &replacement_path)); | 933 &replacement_path)); |
| 923 PrerenderTestURL(replacement_path, FINAL_STATUS_USED, 1); | 934 PrerenderTestURL(replacement_path, FINAL_STATUS_USED, 1); |
| 924 NavigateToDestURL(); | 935 NavigateToDestURL(); |
| 925 } | 936 } |
| 926 | 937 |
| 927 } // namespace prerender | 938 } // namespace prerender |
| OLD | NEW |