Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(353)

Side by Side Diff: chrome/browser/chromeos/offline/offline_load_page_unittest.cc

Issue 11413050: chrome/browser: Update calls from RunAllPending() to RunUntilIdle(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/test/base/chrome_render_view_host_test_harness.h" 7 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
8 #include "content/public/browser/interstitial_page.h" 8 #include "content/public/browser/interstitial_page.h"
9 #include "content/public/browser/navigation_controller.h" 9 #include "content/public/browser/navigation_controller.h"
10 #include "content/public/browser/web_contents.h" 10 #include "content/public/browser/web_contents.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 Navigate(kURL1, 1); 110 Navigate(kURL1, 1);
111 // Load next page. 111 // Load next page.
112 controller().LoadURL(GURL(kURL2), content::Referrer(), 112 controller().LoadURL(GURL(kURL2), content::Referrer(),
113 content::PAGE_TRANSITION_TYPED, std::string()); 113 content::PAGE_TRANSITION_TYPED, std::string());
114 114
115 // Simulate the load causing an offline browsing interstitial page 115 // Simulate the load causing an offline browsing interstitial page
116 // to be shown. 116 // to be shown.
117 ShowInterstitial(kURL2); 117 ShowInterstitial(kURL2);
118 InterstitialPage* interstitial = GetOfflineLoadPage(); 118 InterstitialPage* interstitial = GetOfflineLoadPage();
119 ASSERT_TRUE(interstitial); 119 ASSERT_TRUE(interstitial);
120 MessageLoop::current()->RunAllPending(); 120 MessageLoop::current()->RunUntilIdle();
121 121
122 // Simulate the user clicking "proceed". 122 // Simulate the user clicking "proceed".
123 interstitial->Proceed(); 123 interstitial->Proceed();
124 MessageLoop::current()->RunAllPending(); 124 MessageLoop::current()->RunUntilIdle();
125 125
126 EXPECT_EQ(OK, user_response()); 126 EXPECT_EQ(OK, user_response());
127 127
128 // The URL remains to be URL2. 128 // The URL remains to be URL2.
129 EXPECT_EQ(kURL2, web_contents()->GetURL().spec()); 129 EXPECT_EQ(kURL2, web_contents()->GetURL().spec());
130 130
131 // Commit navigation and the interstitial page is gone. 131 // Commit navigation and the interstitial page is gone.
132 Navigate(kURL2, 2); 132 Navigate(kURL2, 2);
133 EXPECT_FALSE(GetOfflineLoadPage()); 133 EXPECT_FALSE(GetOfflineLoadPage());
134 } 134 }
135 135
136 // Tests showing an offline page and not proceeding. 136 // Tests showing an offline page and not proceeding.
137 TEST_F(OfflineLoadPageTest, OfflinePageDontProceed) { 137 TEST_F(OfflineLoadPageTest, OfflinePageDontProceed) {
138 // Start a load. 138 // Start a load.
139 Navigate(kURL1, 1); 139 Navigate(kURL1, 1);
140 controller().LoadURL(GURL(kURL2), content::Referrer(), 140 controller().LoadURL(GURL(kURL2), content::Referrer(),
141 content::PAGE_TRANSITION_TYPED, std::string()); 141 content::PAGE_TRANSITION_TYPED, std::string());
142 142
143 // Simulate the load causing an offline interstitial page to be shown. 143 // Simulate the load causing an offline interstitial page to be shown.
144 ShowInterstitial(kURL2); 144 ShowInterstitial(kURL2);
145 InterstitialPage* interstitial = GetOfflineLoadPage(); 145 InterstitialPage* interstitial = GetOfflineLoadPage();
146 ASSERT_TRUE(interstitial); 146 ASSERT_TRUE(interstitial);
147 MessageLoop::current()->RunAllPending(); 147 MessageLoop::current()->RunUntilIdle();
148 148
149 // Simulate the user clicking "don't proceed". 149 // Simulate the user clicking "don't proceed".
150 interstitial->DontProceed(); 150 interstitial->DontProceed();
151 151
152 // The interstitial should be gone. 152 // The interstitial should be gone.
153 EXPECT_EQ(CANCEL, user_response()); 153 EXPECT_EQ(CANCEL, user_response());
154 EXPECT_FALSE(GetOfflineLoadPage()); 154 EXPECT_FALSE(GetOfflineLoadPage());
155 // We did not proceed, the pending entry should be gone. 155 // We did not proceed, the pending entry should be gone.
156 EXPECT_FALSE(controller().GetPendingEntry()); 156 EXPECT_FALSE(controller().GetPendingEntry());
157 // the URL is set back to kURL1. 157 // the URL is set back to kURL1.
158 EXPECT_EQ(kURL1, web_contents()->GetURL().spec()); 158 EXPECT_EQ(kURL1, web_contents()->GetURL().spec());
159 } 159 }
160 160
161 } // namespace chromeos 161 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698