OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/android/offline_pages/prerendering_loader.h" | 5 #include "chrome/browser/android/offline_pages/prerendering_loader.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 EXPECT_FALSE(loader()->IsLoaded()); | 216 EXPECT_FALSE(loader()->IsLoaded()); |
217 EXPECT_TRUE(loader()->LoadPage( | 217 EXPECT_TRUE(loader()->LoadPage( |
218 gurl, | 218 gurl, |
219 base::Bind(&PrerenderingLoaderTest::OnLoadDone, base::Unretained(this)))); | 219 base::Bind(&PrerenderingLoaderTest::OnLoadDone, base::Unretained(this)))); |
220 | 220 |
221 PumpLoop(); | 221 PumpLoop(); |
222 EXPECT_FALSE(loader()->IsIdle()); | 222 EXPECT_FALSE(loader()->IsIdle()); |
223 EXPECT_FALSE(loader()->IsLoaded()); | 223 EXPECT_FALSE(loader()->IsLoaded()); |
224 | 224 |
225 test_adapter()->GetObserver()->OnPrerenderStopLoading(); | 225 test_adapter()->GetObserver()->OnPrerenderStopLoading(); |
| 226 // Skip SnapshotController's wait time and emulate StartSnapshot call. |
| 227 loader()->StartSnapshot(); |
226 PumpLoop(); | 228 PumpLoop(); |
227 EXPECT_FALSE(loader()->IsIdle()); | 229 EXPECT_FALSE(loader()->IsIdle()); |
228 EXPECT_TRUE(loader()->IsLoaded()); | 230 EXPECT_TRUE(loader()->IsLoaded()); |
229 EXPECT_TRUE(callback_called()); | 231 EXPECT_TRUE(callback_called()); |
230 EXPECT_EQ(Offliner::RequestStatus::LOADED, callback_load_status()); | 232 EXPECT_EQ(Offliner::RequestStatus::LOADED, callback_load_status()); |
231 | 233 |
232 // Consider Prerenderer stops (eg, times out) before Loader is done with it. | 234 // Consider Prerenderer stops (eg, times out) before Loader is done with it. |
233 test_adapter()->GetObserver()->OnPrerenderStop(); | 235 test_adapter()->GetObserver()->OnPrerenderStop(); |
234 PumpLoop(); | 236 PumpLoop(); |
235 EXPECT_TRUE(loader()->IsIdle()); | 237 EXPECT_TRUE(loader()->IsIdle()); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 test_adapter()->FailStart(); | 383 test_adapter()->FailStart(); |
382 GURL gurl("http://testit.sea"); | 384 GURL gurl("http://testit.sea"); |
383 EXPECT_TRUE(loader()->IsIdle()); | 385 EXPECT_TRUE(loader()->IsIdle()); |
384 EXPECT_FALSE(loader()->LoadPage( | 386 EXPECT_FALSE(loader()->LoadPage( |
385 gurl, | 387 gurl, |
386 base::Bind(&PrerenderingLoaderTest::OnLoadDone, base::Unretained(this)))); | 388 base::Bind(&PrerenderingLoaderTest::OnLoadDone, base::Unretained(this)))); |
387 EXPECT_TRUE(loader()->IsIdle()); | 389 EXPECT_TRUE(loader()->IsIdle()); |
388 } | 390 } |
389 | 391 |
390 } // namespace offline_pages | 392 } // namespace offline_pages |
OLD | NEW |