| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef IOS_WEB_PUBLIC_TEST_FAKES_TEST_NAVIGATION_MANAGER_H_ | 5 #ifndef IOS_WEB_PUBLIC_TEST_FAKES_TEST_NAVIGATION_MANAGER_H_ |
| 6 #define IOS_WEB_PUBLIC_TEST_FAKES_TEST_NAVIGATION_MANAGER_H_ | 6 #define IOS_WEB_PUBLIC_TEST_FAKES_TEST_NAVIGATION_MANAGER_H_ |
| 7 | 7 |
| 8 #import "ios/web/public/navigation_item.h" |
| 9 #include "ios/web/public/navigation_item_list.h" |
| 8 #import "ios/web/public/navigation_manager.h" | 10 #import "ios/web/public/navigation_manager.h" |
| 11 #include "ui/base/page_transition_types.h" |
| 9 | 12 |
| 10 namespace web { | 13 namespace web { |
| 11 | 14 |
| 12 // A minimal implementation of web::NavigationManager that raises NOTREACHED() | 15 // A minimal implementation of web::NavigationManager that raises NOTREACHED() |
| 13 // on most calls. | 16 // on most calls. |
| 14 class TestNavigationManager : public web::NavigationManager { | 17 class TestNavigationManager : public web::NavigationManager { |
| 15 public: | 18 public: |
| 16 TestNavigationManager(); | 19 TestNavigationManager(); |
| 17 ~TestNavigationManager() override; | 20 ~TestNavigationManager() override; |
| 18 BrowserState* GetBrowserState() const override; | 21 BrowserState* GetBrowserState() const override; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 35 bool CanGoBack() const override; | 38 bool CanGoBack() const override; |
| 36 bool CanGoForward() const override; | 39 bool CanGoForward() const override; |
| 37 bool CanGoToOffset(int offset) const override; | 40 bool CanGoToOffset(int offset) const override; |
| 38 void GoBack() override; | 41 void GoBack() override; |
| 39 void GoForward() override; | 42 void GoForward() override; |
| 40 void GoToIndex(int index) override; | 43 void GoToIndex(int index) override; |
| 41 void Reload(ReloadType reload_type, bool check_for_reposts) override; | 44 void Reload(ReloadType reload_type, bool check_for_reposts) override; |
| 42 void OverrideDesktopUserAgentForNextPendingItem() override; | 45 void OverrideDesktopUserAgentForNextPendingItem() override; |
| 43 | 46 |
| 44 // Setters for test data. | 47 // Setters for test data. |
| 48 // Sets a value for last committed item that will be returned by |
| 49 // GetLastCommittedItem(). |
| 45 void SetLastCommittedItem(NavigationItem* item); | 50 void SetLastCommittedItem(NavigationItem* item); |
| 51 |
| 52 // Sets a value for pending item that will be returned by GetPendingItem(). |
| 46 void SetPendingItem(NavigationItem* item); | 53 void SetPendingItem(NavigationItem* item); |
| 54 |
| 55 // Sets a value for visible item that will be returned by GetVisibleItem(). |
| 47 void SetVisibleItem(NavigationItem* item); | 56 void SetVisibleItem(NavigationItem* item); |
| 48 | 57 |
| 58 // Adds an item to items_. Affects the return values for, GetItemCount(), |
| 59 // GetItemAtIndex(), and GetCurrentItemIndex(). |
| 60 void AddItem(const GURL& url, ui::PageTransition transition); |
| 61 |
| 62 // Sets the index to be returned by GetCurrentItemIndex(). |index| must be |
| 63 // either -1 or between 0 and GetItemCount()-1, inclusively. |
| 64 void SetCurrentItemIndex(const int index); |
| 65 |
| 49 private: | 66 private: |
| 67 // A list of items constructed by calling AddItem(). |
| 68 web::ScopedNavigationItemList items_; |
| 69 int items_index_; |
| 70 // Individual backing instance variables for Set* test set up methods. |
| 50 NavigationItem* pending_item_; | 71 NavigationItem* pending_item_; |
| 51 NavigationItem* last_committed_item_; | 72 NavigationItem* last_committed_item_; |
| 52 NavigationItem* visible_item_; | 73 NavigationItem* visible_item_; |
| 53 }; | 74 }; |
| 54 | 75 |
| 55 } // namespace web | 76 } // namespace web |
| 56 | 77 |
| 57 #endif // IOS_WEB_PUBLIC_TEST_FAKES_TEST_NAVIGATION_MANAGER_H_ | 78 #endif // IOS_WEB_PUBLIC_TEST_FAKES_TEST_NAVIGATION_MANAGER_H_ |
| OLD | NEW |