| 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 "chrome/browser/chromeos/cros/cros_library.h" | 5 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 6 #include "chrome/browser/chromeos/offline/offline_load_page.h" | 6 #include "chrome/browser/chromeos/offline/offline_load_page.h" |
| 7 #include "chrome/browser/renderer_host/offline_resource_handler.h" | 7 #include "chrome/browser/renderer_host/offline_resource_handler.h" |
| 8 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 8 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 9 #include "content/browser/tab_contents/navigation_entry.h" | 9 #include "content/browser/tab_contents/navigation_entry.h" |
| 10 #include "content/browser/tab_contents/test_tab_contents.h" | 10 #include "content/browser/tab_contents/test_tab_contents.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 | 106 |
| 107 void TestOfflineLoadPage::NotifyBlockingPageComplete(bool proceed) { | 107 void TestOfflineLoadPage::NotifyBlockingPageComplete(bool proceed) { |
| 108 test_page_->OnBlockingPageComplete(proceed); | 108 test_page_->OnBlockingPageComplete(proceed); |
| 109 } | 109 } |
| 110 | 110 |
| 111 | 111 |
| 112 TEST_F(OfflineLoadPageTest, OfflinePageProceed) { | 112 TEST_F(OfflineLoadPageTest, OfflinePageProceed) { |
| 113 // Start a load. | 113 // Start a load. |
| 114 Navigate(kURL1, 1); | 114 Navigate(kURL1, 1); |
| 115 // Load next page. | 115 // Load next page. |
| 116 controller().LoadURL(GURL(kURL2), GURL(), content::PAGE_TRANSITION_TYPED, | 116 controller().LoadURL(GURL(kURL2), content::Referrer(), |
| 117 std::string()); | 117 content::PAGE_TRANSITION_TYPED, std::string()); |
| 118 | 118 |
| 119 // Simulate the load causing an offline browsing interstitial page | 119 // Simulate the load causing an offline browsing interstitial page |
| 120 // to be shown. | 120 // to be shown. |
| 121 ShowInterstitial(kURL2); | 121 ShowInterstitial(kURL2); |
| 122 InterstitialPage* interstitial = GetOfflineLoadPage(); | 122 InterstitialPage* interstitial = GetOfflineLoadPage(); |
| 123 ASSERT_TRUE(interstitial); | 123 ASSERT_TRUE(interstitial); |
| 124 MessageLoop::current()->RunAllPending(); | 124 MessageLoop::current()->RunAllPending(); |
| 125 | 125 |
| 126 // Simulate the user clicking "proceed". | 126 // Simulate the user clicking "proceed". |
| 127 interstitial->Proceed(); | 127 interstitial->Proceed(); |
| 128 MessageLoop::current()->RunAllPending(); | 128 MessageLoop::current()->RunAllPending(); |
| 129 | 129 |
| 130 EXPECT_EQ(OK, user_response()); | 130 EXPECT_EQ(OK, user_response()); |
| 131 | 131 |
| 132 // The URL remains to be URL2. | 132 // The URL remains to be URL2. |
| 133 EXPECT_EQ(kURL2, contents()->GetURL().spec()); | 133 EXPECT_EQ(kURL2, contents()->GetURL().spec()); |
| 134 | 134 |
| 135 // Commit navigation and the interstitial page is gone. | 135 // Commit navigation and the interstitial page is gone. |
| 136 Navigate(kURL2, 2); | 136 Navigate(kURL2, 2); |
| 137 EXPECT_FALSE(GetOfflineLoadPage()); | 137 EXPECT_FALSE(GetOfflineLoadPage()); |
| 138 } | 138 } |
| 139 | 139 |
| 140 // Tests showing an offline page and not proceeding. | 140 // Tests showing an offline page and not proceeding. |
| 141 TEST_F(OfflineLoadPageTest, OfflinePageDontProceed) { | 141 TEST_F(OfflineLoadPageTest, OfflinePageDontProceed) { |
| 142 // Start a load. | 142 // Start a load. |
| 143 Navigate(kURL1, 1); | 143 Navigate(kURL1, 1); |
| 144 controller().LoadURL(GURL(kURL2), GURL(), content::PAGE_TRANSITION_TYPED, | 144 controller().LoadURL(GURL(kURL2), content::Referrer(), |
| 145 std::string()); | 145 content::PAGE_TRANSITION_TYPED, std::string()); |
| 146 | 146 |
| 147 // Simulate the load causing an offline interstitial page to be shown. | 147 // Simulate the load causing an offline interstitial page to be shown. |
| 148 ShowInterstitial(kURL2); | 148 ShowInterstitial(kURL2); |
| 149 InterstitialPage* interstitial = GetOfflineLoadPage(); | 149 InterstitialPage* interstitial = GetOfflineLoadPage(); |
| 150 ASSERT_TRUE(interstitial); | 150 ASSERT_TRUE(interstitial); |
| 151 MessageLoop::current()->RunAllPending(); | 151 MessageLoop::current()->RunAllPending(); |
| 152 | 152 |
| 153 // Simulate the user clicking "don't proceed". | 153 // Simulate the user clicking "don't proceed". |
| 154 interstitial->DontProceed(); | 154 interstitial->DontProceed(); |
| 155 | 155 |
| 156 // The interstitial should be gone. | 156 // The interstitial should be gone. |
| 157 EXPECT_EQ(CANCEL, user_response()); | 157 EXPECT_EQ(CANCEL, user_response()); |
| 158 EXPECT_FALSE(GetOfflineLoadPage()); | 158 EXPECT_FALSE(GetOfflineLoadPage()); |
| 159 // We did not proceed, the pending entry should be gone. | 159 // We did not proceed, the pending entry should be gone. |
| 160 EXPECT_FALSE(controller().pending_entry()); | 160 EXPECT_FALSE(controller().pending_entry()); |
| 161 // the URL is set back to kURL1. | 161 // the URL is set back to kURL1. |
| 162 EXPECT_EQ(kURL1, contents()->GetURL().spec()); | 162 EXPECT_EQ(kURL1, contents()->GetURL().spec()); |
| 163 } | 163 } |
| 164 | 164 |
| 165 } // namespace chromeos | 165 } // namespace chromeos |
| OLD | NEW |