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

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

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 class OfflineLoadPageTest : public ChromeRenderViewHostTestHarness { 46 class OfflineLoadPageTest : public ChromeRenderViewHostTestHarness {
47 public: 47 public:
48 // The decision the user made. 48 // The decision the user made.
49 enum UserResponse { 49 enum UserResponse {
50 PENDING, 50 PENDING,
51 OK, 51 OK,
52 CANCEL 52 CANCEL
53 }; 53 };
54 54
55 OfflineLoadPageTest() 55 OfflineLoadPageTest()
56 : ui_thread_(BrowserThread::UI, MessageLoop::current()), 56 : ui_thread_(BrowserThread::UI, base::MessageLoop::current()),
57 file_user_blocking_thread_( 57 file_user_blocking_thread_(BrowserThread::FILE_USER_BLOCKING,
58 BrowserThread::FILE_USER_BLOCKING, MessageLoop::current()), 58 base::MessageLoop::current()),
59 io_thread_(BrowserThread::IO, MessageLoop::current()) { 59 io_thread_(BrowserThread::IO, base::MessageLoop::current()) {}
60 }
61 60
62 virtual void SetUp() { 61 virtual void SetUp() {
63 ChromeRenderViewHostTestHarness::SetUp(); 62 ChromeRenderViewHostTestHarness::SetUp();
64 user_response_ = PENDING; 63 user_response_ = PENDING;
65 } 64 }
66 65
67 void OnBlockingPageComplete(bool proceed) { 66 void OnBlockingPageComplete(bool proceed) {
68 if (proceed) 67 if (proceed)
69 user_response_ = OK; 68 user_response_ = OK;
70 else 69 else
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 Navigate(kURL1, 1); 109 Navigate(kURL1, 1);
111 // Load next page. 110 // Load next page.
112 controller().LoadURL(GURL(kURL2), content::Referrer(), 111 controller().LoadURL(GURL(kURL2), content::Referrer(),
113 content::PAGE_TRANSITION_TYPED, std::string()); 112 content::PAGE_TRANSITION_TYPED, std::string());
114 113
115 // Simulate the load causing an offline browsing interstitial page 114 // Simulate the load causing an offline browsing interstitial page
116 // to be shown. 115 // to be shown.
117 ShowInterstitial(kURL2); 116 ShowInterstitial(kURL2);
118 InterstitialPage* interstitial = GetOfflineLoadPage(); 117 InterstitialPage* interstitial = GetOfflineLoadPage();
119 ASSERT_TRUE(interstitial); 118 ASSERT_TRUE(interstitial);
120 MessageLoop::current()->RunUntilIdle(); 119 base::MessageLoop::current()->RunUntilIdle();
121 120
122 // Simulate the user clicking "proceed". 121 // Simulate the user clicking "proceed".
123 interstitial->Proceed(); 122 interstitial->Proceed();
124 MessageLoop::current()->RunUntilIdle(); 123 base::MessageLoop::current()->RunUntilIdle();
125 124
126 EXPECT_EQ(OK, user_response()); 125 EXPECT_EQ(OK, user_response());
127 126
128 // The URL remains to be URL2. 127 // The URL remains to be URL2.
129 EXPECT_EQ(kURL2, web_contents()->GetURL().spec()); 128 EXPECT_EQ(kURL2, web_contents()->GetURL().spec());
130 129
131 // Commit navigation and the interstitial page is gone. 130 // Commit navigation and the interstitial page is gone.
132 Navigate(kURL2, 2); 131 Navigate(kURL2, 2);
133 EXPECT_FALSE(GetOfflineLoadPage()); 132 EXPECT_FALSE(GetOfflineLoadPage());
134 } 133 }
135 134
136 // Tests showing an offline page and not proceeding. 135 // Tests showing an offline page and not proceeding.
137 TEST_F(OfflineLoadPageTest, OfflinePageDontProceed) { 136 TEST_F(OfflineLoadPageTest, OfflinePageDontProceed) {
138 // Start a load. 137 // Start a load.
139 Navigate(kURL1, 1); 138 Navigate(kURL1, 1);
140 controller().LoadURL(GURL(kURL2), content::Referrer(), 139 controller().LoadURL(GURL(kURL2), content::Referrer(),
141 content::PAGE_TRANSITION_TYPED, std::string()); 140 content::PAGE_TRANSITION_TYPED, std::string());
142 141
143 // Simulate the load causing an offline interstitial page to be shown. 142 // Simulate the load causing an offline interstitial page to be shown.
144 ShowInterstitial(kURL2); 143 ShowInterstitial(kURL2);
145 InterstitialPage* interstitial = GetOfflineLoadPage(); 144 InterstitialPage* interstitial = GetOfflineLoadPage();
146 ASSERT_TRUE(interstitial); 145 ASSERT_TRUE(interstitial);
147 MessageLoop::current()->RunUntilIdle(); 146 base::MessageLoop::current()->RunUntilIdle();
148 147
149 // Simulate the user clicking "don't proceed". 148 // Simulate the user clicking "don't proceed".
150 interstitial->DontProceed(); 149 interstitial->DontProceed();
151 150
152 // The interstitial should be gone. 151 // The interstitial should be gone.
153 EXPECT_EQ(CANCEL, user_response()); 152 EXPECT_EQ(CANCEL, user_response());
154 EXPECT_FALSE(GetOfflineLoadPage()); 153 EXPECT_FALSE(GetOfflineLoadPage());
155 // We did not proceed, the pending entry should be gone. 154 // We did not proceed, the pending entry should be gone.
156 EXPECT_FALSE(controller().GetPendingEntry()); 155 EXPECT_FALSE(controller().GetPendingEntry());
157 // the URL is set back to kURL1. 156 // the URL is set back to kURL1.
158 EXPECT_EQ(kURL1, web_contents()->GetURL().spec()); 157 EXPECT_EQ(kURL1, web_contents()->GetURL().spec());
159 } 158 }
160 159
161 } // namespace chromeos 160 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698