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

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

Issue 3537005: Merge 58701 - Relanding this:... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/517/src/
Patch Set: Created 10 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/renderer_host/test/test_render_view_host.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/back_forward_menu_model.h" 5 #include "chrome/browser/back_forward_menu_model.h"
6 6
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/profile_manager.h" 10 #include "chrome/browser/profile_manager.h"
(...skipping 22 matching lines...) Expand all
33 33
34 void LoadURLAndUpdateState(const char* url, const char* title) { 34 void LoadURLAndUpdateState(const char* url, const char* title) {
35 NavigateAndCommit(GURL(url)); 35 NavigateAndCommit(GURL(url));
36 controller().GetLastCommittedEntry()->set_title(UTF8ToUTF16(title)); 36 controller().GetLastCommittedEntry()->set_title(UTF8ToUTF16(title));
37 } 37 }
38 38
39 // Navigate back or forward the given amount and commits the entry (which 39 // Navigate back or forward the given amount and commits the entry (which
40 // will be pending after we ask to navigate there). 40 // will be pending after we ask to navigate there).
41 void NavigateToOffset(int offset) { 41 void NavigateToOffset(int offset) {
42 controller().GoToOffset(offset); 42 controller().GoToOffset(offset);
43 const NavigationEntry* entry = controller().pending_entry(); 43 contents()->CommitPendingNavigation();
44 rvh()->SendNavigate(entry->page_id(), entry->url());
45 } 44 }
46 45
47 // Same as NavigateToOffset but goes to an absolute index. 46 // Same as NavigateToOffset but goes to an absolute index.
48 void NavigateToIndex(int index) { 47 void NavigateToIndex(int index) {
49 controller().GoToIndex(index); 48 controller().GoToIndex(index);
50 const NavigationEntry* entry = controller().pending_entry(); 49 contents()->CommitPendingNavigation();
51 rvh()->SendNavigate(entry->page_id(), entry->url());
52 } 50 }
53 51
54 // Goes back/forward and commits the load. 52 // Goes back/forward and commits the load.
55 void GoBack() { 53 void GoBack() {
56 controller().GoBack(); 54 controller().GoBack();
57 const NavigationEntry* entry = controller().pending_entry(); 55 contents()->CommitPendingNavigation();
58 rvh()->SendNavigate(entry->page_id(), entry->url());
59 } 56 }
60 void GoForward() { 57 void GoForward() {
61 controller().GoForward(); 58 controller().GoForward();
62 const NavigationEntry* entry = controller().pending_entry(); 59 contents()->CommitPendingNavigation();
63 rvh()->SendNavigate(entry->page_id(), entry->url());
64 } 60 }
65 }; 61 };
66 62
67 TEST_F(BackFwdMenuModelTest, BasicCase) { 63 TEST_F(BackFwdMenuModelTest, BasicCase) {
68 scoped_ptr<BackForwardMenuModel> back_model(new BackForwardMenuModel( 64 scoped_ptr<BackForwardMenuModel> back_model(new BackForwardMenuModel(
69 NULL, BackForwardMenuModel::BACKWARD_MENU)); 65 NULL, BackForwardMenuModel::BACKWARD_MENU));
70 back_model->set_test_tab_contents(contents()); 66 back_model->set_test_tab_contents(contents());
71 67
72 scoped_ptr<BackForwardMenuModel> forward_model(new BackForwardMenuModel( 68 scoped_ptr<BackForwardMenuModel> forward_model(new BackForwardMenuModel(
73 NULL, BackForwardMenuModel::FORWARD_MENU)); 69 NULL, BackForwardMenuModel::FORWARD_MENU));
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 EXPECT_EQ(1, back_model->GetIndexOfNextChapterStop(0, true)); 413 EXPECT_EQ(1, back_model->GetIndexOfNextChapterStop(0, true));
418 EXPECT_EQ(3, back_model->GetIndexOfNextChapterStop(1, true)); 414 EXPECT_EQ(3, back_model->GetIndexOfNextChapterStop(1, true));
419 EXPECT_EQ(3, back_model->GetIndexOfNextChapterStop(2, true)); 415 EXPECT_EQ(3, back_model->GetIndexOfNextChapterStop(2, true));
420 EXPECT_EQ(4, back_model->GetIndexOfNextChapterStop(3, true)); 416 EXPECT_EQ(4, back_model->GetIndexOfNextChapterStop(3, true));
421 // And try backwards as well. 417 // And try backwards as well.
422 EXPECT_EQ(3, back_model->GetIndexOfNextChapterStop(4, false)); 418 EXPECT_EQ(3, back_model->GetIndexOfNextChapterStop(4, false));
423 EXPECT_EQ(1, back_model->GetIndexOfNextChapterStop(3, false)); 419 EXPECT_EQ(1, back_model->GetIndexOfNextChapterStop(3, false));
424 EXPECT_EQ(1, back_model->GetIndexOfNextChapterStop(2, false)); 420 EXPECT_EQ(1, back_model->GetIndexOfNextChapterStop(2, false));
425 EXPECT_EQ(-1, back_model->GetIndexOfNextChapterStop(1, false)); 421 EXPECT_EQ(-1, back_model->GetIndexOfNextChapterStop(1, false));
426 } 422 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/renderer_host/test/test_render_view_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698