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

Side by Side Diff: chrome/browser/navigation_controller_unittest.cc

Issue 17014: Remove compatibility #defines in string_util.h (Closed)
Patch Set: Created 11 years, 11 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
« no previous file with comments | « base/string_util.h ('k') | chrome/test/chrome_plugin/test_chrome_plugin.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/file_util.h" 5 #include "base/file_util.h"
6 #include "base/path_service.h" 6 #include "base/path_service.h"
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "chrome/browser/navigation_controller.h" 8 #include "chrome/browser/navigation_controller.h"
9 #include "chrome/browser/navigation_entry.h" 9 #include "chrome/browser/navigation_entry.h"
10 #include "chrome/browser/profile_manager.h" 10 #include "chrome/browser/profile_manager.h"
(...skipping 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 TEST_F(NavigationControllerTest, EnforceMaxNavigationCount) { 1161 TEST_F(NavigationControllerTest, EnforceMaxNavigationCount) {
1162 size_t original_count = NavigationController::max_entry_count(); 1162 size_t original_count = NavigationController::max_entry_count();
1163 const size_t kMaxEntryCount = 5; 1163 const size_t kMaxEntryCount = 5;
1164 1164
1165 NavigationController::set_max_entry_count(kMaxEntryCount); 1165 NavigationController::set_max_entry_count(kMaxEntryCount);
1166 1166
1167 int url_index; 1167 int url_index;
1168 char buffer[128]; 1168 char buffer[128];
1169 // Load up to the max count, all entries should be there. 1169 // Load up to the max count, all entries should be there.
1170 for (url_index = 0; url_index < kMaxEntryCount; url_index++) { 1170 for (url_index = 0; url_index < kMaxEntryCount; url_index++) {
1171 SNPrintF(buffer, 128, (scheme1() + "://www.a.com/%d").c_str(), url_index); 1171 base::snprintf(buffer, 128, (scheme1() + "://www.a.com/%d").c_str(),
1172 url_index);
1172 GURL url(buffer); 1173 GURL url(buffer);
1173 contents->controller()->LoadURL(url, GURL(), PageTransition::TYPED); 1174 contents->controller()->LoadURL(url, GURL(), PageTransition::TYPED);
1174 contents->CompleteNavigationAsRenderer(url_index, url); 1175 contents->CompleteNavigationAsRenderer(url_index, url);
1175 } 1176 }
1176 1177
1177 EXPECT_EQ(contents->controller()->GetEntryCount(), kMaxEntryCount); 1178 EXPECT_EQ(contents->controller()->GetEntryCount(), kMaxEntryCount);
1178 1179
1179 // Created a PrunedListener to observe prune notifications. 1180 // Created a PrunedListener to observe prune notifications.
1180 PrunedListener listener(contents->controller()); 1181 PrunedListener listener(contents->controller());
1181 1182
1182 // Navigate some more. 1183 // Navigate some more.
1183 SNPrintF(buffer, 128, (scheme1() + "://www.a.com/%d").c_str(), url_index); 1184 base::snprintf(buffer, 128, (scheme1() + "://www.a.com/%d").c_str(),
1185 url_index);
1184 GURL url(buffer); 1186 GURL url(buffer);
1185 contents->controller()->LoadURL(url, GURL(), PageTransition::TYPED); 1187 contents->controller()->LoadURL(url, GURL(), PageTransition::TYPED);
1186 contents->CompleteNavigationAsRenderer(url_index, url); 1188 contents->CompleteNavigationAsRenderer(url_index, url);
1187 url_index++; 1189 url_index++;
1188 1190
1189 // We should have got a pruned navigation. 1191 // We should have got a pruned navigation.
1190 EXPECT_EQ(1, listener.notification_count_); 1192 EXPECT_EQ(1, listener.notification_count_);
1191 EXPECT_TRUE(listener.details_.from_front); 1193 EXPECT_TRUE(listener.details_.from_front);
1192 EXPECT_EQ(1, listener.details_.count); 1194 EXPECT_EQ(1, listener.details_.count);
1193 1195
1194 // We expect http://www.a.com/0 to be gone. 1196 // We expect http://www.a.com/0 to be gone.
1195 EXPECT_EQ(contents->controller()->GetEntryCount(), kMaxEntryCount); 1197 EXPECT_EQ(contents->controller()->GetEntryCount(), kMaxEntryCount);
1196 EXPECT_EQ(contents->controller()->GetEntryAtIndex(0)->url(), 1198 EXPECT_EQ(contents->controller()->GetEntryAtIndex(0)->url(),
1197 GURL(scheme1() + "://www.a.com/1")); 1199 GURL(scheme1() + "://www.a.com/1"));
1198 1200
1199 // More navigations. 1201 // More navigations.
1200 for (int i = 0; i < 3; i++) { 1202 for (int i = 0; i < 3; i++) {
1201 SNPrintF(buffer, 128, (scheme1() + "://www.a.com/%d").c_str(), url_index); 1203 base::snprintf(buffer, 128, (scheme1() + "://www.a.com/%d").c_str(),
1204 url_index);
1202 url = GURL(buffer); 1205 url = GURL(buffer);
1203 contents->controller()->LoadURL(url, GURL(), PageTransition::TYPED); 1206 contents->controller()->LoadURL(url, GURL(), PageTransition::TYPED);
1204 contents->CompleteNavigationAsRenderer(url_index, url); 1207 contents->CompleteNavigationAsRenderer(url_index, url);
1205 url_index++; 1208 url_index++;
1206 } 1209 }
1207 EXPECT_EQ(contents->controller()->GetEntryCount(), kMaxEntryCount); 1210 EXPECT_EQ(contents->controller()->GetEntryCount(), kMaxEntryCount);
1208 EXPECT_EQ(contents->controller()->GetEntryAtIndex(0)->url(), 1211 EXPECT_EQ(contents->controller()->GetEntryAtIndex(0)->url(),
1209 GURL(scheme1() + "://www.a.com/4")); 1212 GURL(scheme1() + "://www.a.com/4"));
1210 1213
1211 NavigationController::set_max_entry_count(original_count); 1214 NavigationController::set_max_entry_count(original_count);
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
1578 1581
1579 helper_.AssertSingleWindowWithSingleTab(windows_, 2); 1582 helper_.AssertSingleWindowWithSingleTab(windows_, 2);
1580 helper_.AssertTabEquals(0, 1, 2, *(windows_[0]->tabs[0])); 1583 helper_.AssertTabEquals(0, 1, 2, *(windows_[0]->tabs[0]));
1581 1584
1582 TabNavigation nav(0, url0, GURL(), std::wstring(), std::string(), 1585 TabNavigation nav(0, url0, GURL(), std::wstring(), std::string(),
1583 PageTransition::LINK); 1586 PageTransition::LINK);
1584 helper_.AssertNavigationEquals(nav, windows_[0]->tabs[0]->navigations[0]); 1587 helper_.AssertNavigationEquals(nav, windows_[0]->tabs[0]->navigations[0]);
1585 nav.set_url(url2); 1588 nav.set_url(url2);
1586 helper_.AssertNavigationEquals(nav, windows_[0]->tabs[0]->navigations[1]); 1589 helper_.AssertNavigationEquals(nav, windows_[0]->tabs[0]->navigations[1]);
1587 } 1590 }
OLDNEW
« no previous file with comments | « base/string_util.h ('k') | chrome/test/chrome_plugin/test_chrome_plugin.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698