| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 test_adapter()->FailStart(); | 336 test_adapter()->FailStart(); |
| 335 GURL gurl("http://testit.sea"); | 337 GURL gurl("http://testit.sea"); |
| 336 EXPECT_TRUE(loader()->IsIdle()); | 338 EXPECT_TRUE(loader()->IsIdle()); |
| 337 EXPECT_FALSE(loader()->LoadPage( | 339 EXPECT_FALSE(loader()->LoadPage( |
| 338 gurl, | 340 gurl, |
| 339 base::Bind(&PrerenderingLoaderTest::OnLoadDone, base::Unretained(this)))); | 341 base::Bind(&PrerenderingLoaderTest::OnLoadDone, base::Unretained(this)))); |
| 340 EXPECT_TRUE(loader()->IsIdle()); | 342 EXPECT_TRUE(loader()->IsIdle()); |
| 341 } | 343 } |
| 342 | 344 |
| 343 } // namespace offline_pages | 345 } // namespace offline_pages |
| OLD | NEW |