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

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: rebase again Created 7 years, 6 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_(
58 BrowserThread::FILE_USER_BLOCKING, MessageLoop::current()), 58 BrowserThread::FILE_USER_BLOCKING, base::MessageLoop::current()),
59 io_thread_(BrowserThread::IO, MessageLoop::current()) { 59 io_thread_(BrowserThread::IO, base::MessageLoop::current()) {
60 } 60 }
61 61
62 virtual void SetUp() { 62 virtual void SetUp() {
63 ChromeRenderViewHostTestHarness::SetUp(); 63 ChromeRenderViewHostTestHarness::SetUp();
64 user_response_ = PENDING; 64 user_response_ = PENDING;
65 } 65 }
66 66
67 void OnBlockingPageComplete(bool proceed) { 67 void OnBlockingPageComplete(bool proceed) {
68 if (proceed) 68 if (proceed)
69 user_response_ = OK; 69 user_response_ = OK;
(...skipping 40 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()->RunUntilIdle(); 120 base::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()->RunUntilIdle(); 124 base::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()->RunUntilIdle(); 147 base::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