| OLD | NEW |
| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 3021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3032 // Prepare some data to use as screenshot for each navigation. | 3032 // Prepare some data to use as screenshot for each navigation. |
| 3033 skia::PlatformBitmap bitmap; | 3033 skia::PlatformBitmap bitmap; |
| 3034 ASSERT_TRUE(bitmap.Allocate(1, 1, false)); | 3034 ASSERT_TRUE(bitmap.Allocate(1, 1, false)); |
| 3035 NavigationEntryImpl* entry; | 3035 NavigationEntryImpl* entry; |
| 3036 | 3036 |
| 3037 // Navigate enough times to make sure that some screenshots are purged. | 3037 // Navigate enough times to make sure that some screenshots are purged. |
| 3038 for (int i = 0; i < 12; ++i) { | 3038 for (int i = 0; i < 12; ++i) { |
| 3039 const GURL url(base::StringPrintf("http://foo%d/", i)); | 3039 const GURL url(base::StringPrintf("http://foo%d/", i)); |
| 3040 NavigateAndCommit(url); | 3040 NavigateAndCommit(url); |
| 3041 EXPECT_EQ(i, controller.GetCurrentEntryIndex()); | 3041 EXPECT_EQ(i, controller.GetCurrentEntryIndex()); |
| 3042 } |
| 3042 | 3043 |
| 3044 for (int i = 0; i < controller.GetEntryCount(); ++i) { |
| 3043 entry = NavigationEntryImpl::FromNavigationEntry( | 3045 entry = NavigationEntryImpl::FromNavigationEntry( |
| 3044 controller.GetActiveEntry()); | 3046 controller.GetEntryAtIndex(i)); |
| 3045 controller.OnScreenshotTaken(entry->GetUniqueID(), &bitmap, true); | 3047 controller.OnScreenshotTaken(entry->GetUniqueID(), &bitmap, true); |
| 3046 EXPECT_TRUE(entry->screenshot()); | 3048 EXPECT_TRUE(entry->screenshot()); |
| 3047 } | 3049 } |
| 3050 |
| 3048 NavigateAndCommit(GURL("https://foo/")); | 3051 NavigateAndCommit(GURL("https://foo/")); |
| 3049 EXPECT_EQ(13, controller.GetEntryCount()); | 3052 EXPECT_EQ(13, controller.GetEntryCount()); |
| 3053 entry = NavigationEntryImpl::FromNavigationEntry( |
| 3054 controller.GetEntryAtIndex(11)); |
| 3055 controller.OnScreenshotTaken(entry->GetUniqueID(), &bitmap, true); |
| 3050 | 3056 |
| 3051 for (int i = 0; i < 2; ++i) { | 3057 for (int i = 0; i < 2; ++i) { |
| 3052 entry = NavigationEntryImpl::FromNavigationEntry( | 3058 entry = NavigationEntryImpl::FromNavigationEntry( |
| 3053 controller.GetEntryAtIndex(i)); | 3059 controller.GetEntryAtIndex(i)); |
| 3054 EXPECT_FALSE(entry->screenshot()) << "Screenshot " << i << " not purged"; | 3060 EXPECT_FALSE(entry->screenshot()) << "Screenshot " << i << " not purged"; |
| 3055 } | 3061 } |
| 3056 | 3062 |
| 3057 for (int i = 2; i < controller.GetEntryCount() - 1; ++i) { | 3063 for (int i = 2; i < controller.GetEntryCount() - 1; ++i) { |
| 3058 entry = NavigationEntryImpl::FromNavigationEntry( | 3064 entry = NavigationEntryImpl::FromNavigationEntry( |
| 3059 controller.GetEntryAtIndex(i)); | 3065 controller.GetEntryAtIndex(i)); |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3277 PAGE_TRANSITION_LINK); | 3283 PAGE_TRANSITION_LINK); |
| 3278 session_helper_.AssertNavigationEquals(nav, | 3284 session_helper_.AssertNavigationEquals(nav, |
| 3279 windows_[0]->tabs[0]->navigations[0]); | 3285 windows_[0]->tabs[0]->navigations[0]); |
| 3280 nav.set_url(url2); | 3286 nav.set_url(url2); |
| 3281 session_helper_.AssertNavigationEquals(nav, | 3287 session_helper_.AssertNavigationEquals(nav, |
| 3282 windows_[0]->tabs[0]->navigations[1]); | 3288 windows_[0]->tabs[0]->navigations[1]); |
| 3283 } | 3289 } |
| 3284 */ | 3290 */ |
| 3285 | 3291 |
| 3286 } // namespace content | 3292 } // namespace content |
| OLD | NEW |