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

Side by Side Diff: chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc

Issue 8687002: Cleanup: Convert ASCIIToUTF16("") to string16(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/ui/toolbar/back_forward_menu_model.h" 5 #include "chrome/browser/ui/toolbar/back_forward_menu_model.h"
6 6
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/string16.h"
8 #include "base/string_util.h" 9 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/history/history.h" 11 #include "chrome/browser/history/history.h"
11 #include "chrome/browser/profiles/profile_manager.h" 12 #include "chrome/browser/profiles/profile_manager.h"
12 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
13 #include "chrome/common/url_constants.h" 14 #include "chrome/common/url_constants.h"
14 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 15 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
15 #include "chrome/test/base/testing_profile.h" 16 #include "chrome/test/base/testing_profile.h"
16 #include "content/browser/tab_contents/navigation_controller.h" 17 #include "content/browser/tab_contents/navigation_controller.h"
17 #include "content/browser/tab_contents/navigation_entry.h" 18 #include "content/browser/tab_contents/navigation_entry.h"
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 // i = 32 339 // i = 32
339 LoadURLAndUpdateState("http://www.k.com/3", "K3"); 340 LoadURLAndUpdateState("http://www.k.com/3", "K3");
340 ValidateModel(back_model.get(), i++, 6); 341 ValidateModel(back_model.get(), i++, 6);
341 342
342 // A chapter stop is defined as the last page the user 343 // A chapter stop is defined as the last page the user
343 // browsed to within the same domain. 344 // browsed to within the same domain.
344 345
345 // Check to see if the chapter stops have the right labels. 346 // Check to see if the chapter stops have the right labels.
346 int index = BackForwardMenuModel::kMaxHistoryItems; 347 int index = BackForwardMenuModel::kMaxHistoryItems;
347 // Empty string indicates item is a separator. 348 // Empty string indicates item is a separator.
348 EXPECT_EQ(ASCIIToUTF16(""), back_model->GetLabelAt(index++)); 349 EXPECT_EQ(string16(), back_model->GetLabelAt(index++));
349 EXPECT_EQ(ASCIIToUTF16("F3"), back_model->GetLabelAt(index++)); 350 EXPECT_EQ(ASCIIToUTF16("F3"), back_model->GetLabelAt(index++));
350 EXPECT_EQ(ASCIIToUTF16("E3"), back_model->GetLabelAt(index++)); 351 EXPECT_EQ(ASCIIToUTF16("E3"), back_model->GetLabelAt(index++));
351 EXPECT_EQ(ASCIIToUTF16("D3"), back_model->GetLabelAt(index++)); 352 EXPECT_EQ(ASCIIToUTF16("D3"), back_model->GetLabelAt(index++));
352 EXPECT_EQ(ASCIIToUTF16("C3"), back_model->GetLabelAt(index++)); 353 EXPECT_EQ(ASCIIToUTF16("C3"), back_model->GetLabelAt(index++));
353 // The menu should only show a maximum of 5 chapter stops. 354 // The menu should only show a maximum of 5 chapter stops.
354 EXPECT_EQ(ASCIIToUTF16("B3"), back_model->GetLabelAt(index)); 355 EXPECT_EQ(ASCIIToUTF16("B3"), back_model->GetLabelAt(index));
355 // Empty string indicates item is a separator. 356 // Empty string indicates item is a separator.
356 EXPECT_EQ(ASCIIToUTF16(""), back_model->GetLabelAt(index + 1)); 357 EXPECT_EQ(string16(), back_model->GetLabelAt(index + 1));
357 EXPECT_EQ(back_model->GetShowFullHistoryLabel(), 358 EXPECT_EQ(back_model->GetShowFullHistoryLabel(),
358 back_model->GetLabelAt(index + 2)); 359 back_model->GetLabelAt(index + 2));
359 360
360 // If we go back two we should still see the same chapter stop at the end. 361 // If we go back two we should still see the same chapter stop at the end.
361 GoBack(); 362 GoBack();
362 EXPECT_EQ(ASCIIToUTF16("B3"), back_model->GetLabelAt(index)); 363 EXPECT_EQ(ASCIIToUTF16("B3"), back_model->GetLabelAt(index));
363 GoBack(); 364 GoBack();
364 EXPECT_EQ(ASCIIToUTF16("B3"), back_model->GetLabelAt(index)); 365 EXPECT_EQ(ASCIIToUTF16("B3"), back_model->GetLabelAt(index));
365 // But if we go back again, it should change. 366 // But if we go back again, it should change.
366 GoBack(); 367 GoBack();
367 EXPECT_EQ(ASCIIToUTF16("A3"), back_model->GetLabelAt(index)); 368 EXPECT_EQ(ASCIIToUTF16("A3"), back_model->GetLabelAt(index));
368 GoBack(); 369 GoBack();
369 EXPECT_EQ(ASCIIToUTF16("A3"), back_model->GetLabelAt(index)); 370 EXPECT_EQ(ASCIIToUTF16("A3"), back_model->GetLabelAt(index));
370 GoBack(); 371 GoBack();
371 EXPECT_EQ(ASCIIToUTF16("A3"), back_model->GetLabelAt(index)); 372 EXPECT_EQ(ASCIIToUTF16("A3"), back_model->GetLabelAt(index));
372 GoBack(); 373 GoBack();
373 // It is now a separator. 374 // It is now a separator.
374 EXPECT_EQ(ASCIIToUTF16(""), back_model->GetLabelAt(index)); 375 EXPECT_EQ(string16(), back_model->GetLabelAt(index));
375 // Undo our position change. 376 // Undo our position change.
376 NavigateToOffset(6); 377 NavigateToOffset(6);
377 378
378 // Go back enough to make sure no chapter stops should appear. 379 // Go back enough to make sure no chapter stops should appear.
379 NavigateToOffset(-BackForwardMenuModel::kMaxHistoryItems); 380 NavigateToOffset(-BackForwardMenuModel::kMaxHistoryItems);
380 ValidateModel(forward_model.get(), BackForwardMenuModel::kMaxHistoryItems, 0); 381 ValidateModel(forward_model.get(), BackForwardMenuModel::kMaxHistoryItems, 0);
381 // Go forward (still no chapter stop) 382 // Go forward (still no chapter stop)
382 GoForward(); 383 GoForward();
383 ValidateModel(forward_model.get(), 384 ValidateModel(forward_model.get(),
384 BackForwardMenuModel::kMaxHistoryItems - 1, 0); 385 BackForwardMenuModel::kMaxHistoryItems - 1, 0);
385 // Go back two (one chapter stop should show up) 386 // Go back two (one chapter stop should show up)
386 GoBack(); 387 GoBack();
387 GoBack(); 388 GoBack();
388 ValidateModel(forward_model.get(), 389 ValidateModel(forward_model.get(),
389 BackForwardMenuModel::kMaxHistoryItems, 1); 390 BackForwardMenuModel::kMaxHistoryItems, 1);
390 391
391 // Go to beginning. 392 // Go to beginning.
392 NavigateToIndex(0); 393 NavigateToIndex(0);
393 394
394 // Check to see if the chapter stops have the right labels. 395 // Check to see if the chapter stops have the right labels.
395 index = BackForwardMenuModel::kMaxHistoryItems; 396 index = BackForwardMenuModel::kMaxHistoryItems;
396 // Empty string indicates item is a separator. 397 // Empty string indicates item is a separator.
397 EXPECT_EQ(ASCIIToUTF16(""), forward_model->GetLabelAt(index++)); 398 EXPECT_EQ(string16(), forward_model->GetLabelAt(index++));
398 EXPECT_EQ(ASCIIToUTF16("E3"), forward_model->GetLabelAt(index++)); 399 EXPECT_EQ(ASCIIToUTF16("E3"), forward_model->GetLabelAt(index++));
399 EXPECT_EQ(ASCIIToUTF16("F3"), forward_model->GetLabelAt(index++)); 400 EXPECT_EQ(ASCIIToUTF16("F3"), forward_model->GetLabelAt(index++));
400 EXPECT_EQ(ASCIIToUTF16("G3"), forward_model->GetLabelAt(index++)); 401 EXPECT_EQ(ASCIIToUTF16("G3"), forward_model->GetLabelAt(index++));
401 EXPECT_EQ(ASCIIToUTF16("H3"), forward_model->GetLabelAt(index++)); 402 EXPECT_EQ(ASCIIToUTF16("H3"), forward_model->GetLabelAt(index++));
402 // The menu should only show a maximum of 5 chapter stops. 403 // The menu should only show a maximum of 5 chapter stops.
403 EXPECT_EQ(ASCIIToUTF16("I3"), forward_model->GetLabelAt(index)); 404 EXPECT_EQ(ASCIIToUTF16("I3"), forward_model->GetLabelAt(index));
404 // Empty string indicates item is a separator. 405 // Empty string indicates item is a separator.
405 EXPECT_EQ(ASCIIToUTF16(""), forward_model->GetLabelAt(index + 1)); 406 EXPECT_EQ(string16(), forward_model->GetLabelAt(index + 1));
406 EXPECT_EQ(forward_model->GetShowFullHistoryLabel(), 407 EXPECT_EQ(forward_model->GetShowFullHistoryLabel(),
407 forward_model->GetLabelAt(index + 2)); 408 forward_model->GetLabelAt(index + 2));
408 409
409 // If we advance one we should still see the same chapter stop at the end. 410 // If we advance one we should still see the same chapter stop at the end.
410 GoForward(); 411 GoForward();
411 EXPECT_EQ(ASCIIToUTF16("I3"), forward_model->GetLabelAt(index)); 412 EXPECT_EQ(ASCIIToUTF16("I3"), forward_model->GetLabelAt(index));
412 // But if we advance one again, it should change. 413 // But if we advance one again, it should change.
413 GoForward(); 414 GoForward();
414 EXPECT_EQ(ASCIIToUTF16("J3"), forward_model->GetLabelAt(index)); 415 EXPECT_EQ(ASCIIToUTF16("J3"), forward_model->GetLabelAt(index));
415 GoForward(); 416 GoForward();
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 // Verify we did get the expected favicon. 551 // Verify we did get the expected favicon.
551 EXPECT_EQ(0, memcmp(new_icon.getPixels(), valid_icon.getPixels(), 552 EXPECT_EQ(0, memcmp(new_icon.getPixels(), valid_icon.getPixels(),
552 new_icon.getSize())); 553 new_icon.getSize()));
553 554
554 // Make sure the browser deconstructor doesn't have problems. 555 // Make sure the browser deconstructor doesn't have problems.
555 browser.CloseAllTabs(); 556 browser.CloseAllTabs();
556 // This is required to prevent the message loop from hanging. 557 // This is required to prevent the message loop from hanging.
557 profile()->DestroyHistoryService(); 558 profile()->DestroyHistoryService();
558 } 559 }
559 560
OLDNEW
« no previous file with comments | « chrome/browser/ui/find_bar/find_bar_host_browsertest.cc ('k') | chrome/browser/ui/webui/flash_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698