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

Side by Side Diff: ios/shared/chrome/browser/tabs/web_state_list_unittest.mm

Issue 2766063002: Remove the concept of currentItemIndex (Closed)
Patch Set: fix unit tests Created 3 years, 9 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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 #import "ios/shared/chrome/browser/tabs/web_state_list.h" 5 #import "ios/shared/chrome/browser/tabs/web_state_list.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/supports_user_data.h" 9 #include "base/supports_user_data.h"
10 #import "ios/shared/chrome/browser/tabs/fake_web_state_list_delegate.h" 10 #import "ios/shared/chrome/browser/tabs/fake_web_state_list_delegate.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 DISALLOW_COPY_AND_ASSIGN(WebStateListTestObserver); 104 DISALLOW_COPY_AND_ASSIGN(WebStateListTestObserver);
105 }; 105 };
106 106
107 // A fake NavigationManager used to test opener-opened relationship in the 107 // A fake NavigationManager used to test opener-opened relationship in the
108 // WebStateList. 108 // WebStateList.
109 class FakeNavigationManager : public web::TestNavigationManager { 109 class FakeNavigationManager : public web::TestNavigationManager {
110 public: 110 public:
111 FakeNavigationManager() = default; 111 FakeNavigationManager() = default;
112 112
113 // web::NavigationManager implementation. 113 // web::NavigationManager implementation.
114 int GetCurrentItemIndex() const override { return current_item_index_; } 114 int GetLastCommittedItemIndex() const override {
115 return last_committed_item_index;
116 }
115 117
116 int GetLastCommittedItemIndex() const override { return current_item_index_; } 118 bool CanGoBack() const override { return last_committed_item_index > 0; }
117 119
118 bool CanGoBack() const override { return current_item_index_ > 0; } 120 bool CanGoForward() const override {
119 121 return last_committed_item_index < INT_MAX;
120 bool CanGoForward() const override { return current_item_index_ < INT_MAX; } 122 }
121 123
122 void GoBack() override { 124 void GoBack() override {
123 DCHECK(CanGoBack()); 125 DCHECK(CanGoBack());
124 --current_item_index_; 126 --last_committed_item_index;
125 } 127 }
126 128
127 void GoForward() override { 129 void GoForward() override {
128 DCHECK(CanGoForward()); 130 DCHECK(CanGoForward());
129 ++current_item_index_; 131 ++last_committed_item_index;
130 } 132 }
131 133
132 void GoToIndex(int index) override { current_item_index_ = index; } 134 void GoToIndex(int index) override { last_committed_item_index = index; }
133 135
134 int current_item_index_ = 0; 136 int last_committed_item_index = 0;
135 137
136 DISALLOW_COPY_AND_ASSIGN(FakeNavigationManager); 138 DISALLOW_COPY_AND_ASSIGN(FakeNavigationManager);
137 }; 139 };
138 140
139 } // namespace 141 } // namespace
140 142
141 class WebStateListTest : public PlatformTest { 143 class WebStateListTest : public PlatformTest {
142 public: 144 public:
143 WebStateListTest() 145 WebStateListTest()
144 : web_state_list_(&web_state_list_delegate_, 146 : web_state_list_(&web_state_list_delegate_,
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 web_state_list_.GetIndexOfLastWebStateOpenedBy(opener, start_index, 539 web_state_list_.GetIndexOfLastWebStateOpenedBy(opener, start_index,
538 false)); 540 false));
539 541
540 EXPECT_EQ(WebStateList::kInvalidIndex, 542 EXPECT_EQ(WebStateList::kInvalidIndex,
541 web_state_list_.GetIndexOfNextWebStateOpenedBy(opener, start_index, 543 web_state_list_.GetIndexOfNextWebStateOpenedBy(opener, start_index,
542 true)); 544 true));
543 EXPECT_EQ(WebStateList::kInvalidIndex, 545 EXPECT_EQ(WebStateList::kInvalidIndex,
544 web_state_list_.GetIndexOfLastWebStateOpenedBy(opener, start_index, 546 web_state_list_.GetIndexOfLastWebStateOpenedBy(opener, start_index,
545 true)); 547 true));
546 } 548 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698