| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 <Foundation/Foundation.h> | 5 #import <Foundation/Foundation.h> |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/mac/scoped_nsobject.h" | 9 #include "base/mac/scoped_nsobject.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "components/bookmarks/browser/bookmark_model.h" | 13 #include "components/bookmarks/browser/bookmark_model.h" |
| 14 #include "components/bookmarks/test/bookmark_test_helpers.h" | 14 #include "components/bookmarks/test/bookmark_test_helpers.h" |
| 15 #include "components/toolbar/test_toolbar_model.h" | 15 #include "components/toolbar/test_toolbar_model.h" |
| 16 #include "ios/chrome/browser/bookmarks/bookmark_model_factory.h" | 16 #include "ios/chrome/browser/bookmarks/bookmark_model_factory.h" |
| 17 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" | 17 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" |
| 18 #include "ios/chrome/browser/ui/toolbar/toolbar_model_delegate_ios.h" | 18 #include "ios/chrome/browser/ui/toolbar/toolbar_model_delegate_ios.h" |
| 19 #include "ios/chrome/browser/ui/toolbar/toolbar_model_impl_ios.h" | 19 #include "ios/chrome/browser/ui/toolbar/toolbar_model_impl_ios.h" |
| 20 #include "ios/chrome/browser/web_state_list/fake_web_state_list_delegate.h" | 20 #include "ios/chrome/browser/web_state_list/fake_web_state_list_delegate.h" |
| 21 #include "ios/chrome/browser/web_state_list/web_state_list.h" | 21 #include "ios/chrome/browser/web_state_list/web_state_list.h" |
| 22 #import "ios/chrome/browser/xcallback_parameters.h" | 22 #import "ios/chrome/browser/xcallback_parameters.h" |
| 23 #import "ios/shared/chrome/browser/ui/toolbar/toolbar_test_util.h" |
| 23 #import "ios/testing/ocmock_complex_type_helper.h" | 24 #import "ios/testing/ocmock_complex_type_helper.h" |
| 24 #import "ios/web/public/test/fakes/test_navigation_manager.h" | 25 #import "ios/web/public/test/fakes/test_navigation_manager.h" |
| 25 #import "ios/web/public/test/fakes/test_web_state.h" | 26 #import "ios/web/public/test/fakes/test_web_state.h" |
| 26 #include "ios/web/public/test/test_web_thread.h" | 27 #include "ios/web/public/test/test_web_thread.h" |
| 27 #include "ios/web/public/test/test_web_thread_bundle.h" | 28 #include "ios/web/public/test/test_web_thread_bundle.h" |
| 28 #include "testing/gtest_mac.h" | 29 #include "testing/gtest_mac.h" |
| 29 #include "testing/platform_test.h" | 30 #include "testing/platform_test.h" |
| 30 #include "third_party/ocmock/gtest_support.h" | 31 #include "third_party/ocmock/gtest_support.h" |
| 31 #include "third_party/ocmock/ocmock_extensions.h" | 32 #include "third_party/ocmock/ocmock_extensions.h" |
| 32 | 33 |
| 33 namespace { | 34 namespace { |
| 34 | 35 |
| 35 static const char kWebUrl[] = "http://www.chromium.org"; | 36 static const char kWebUrl[] = "http://www.chromium.org"; |
| 36 static const char kNativeUrl[] = "chrome://version"; | 37 static const char kNativeUrl[] = "chrome://version"; |
| 37 | 38 |
| 38 namespace { | |
| 39 | |
| 40 class ToolbarTestWebState : public web::TestWebState { | |
| 41 public: | |
| 42 ToolbarTestWebState() : loading_progress_(0) {} | |
| 43 | |
| 44 double GetLoadingProgress() const override { return loading_progress_; } | |
| 45 void set_loading_progress(double loading_progress) { | |
| 46 loading_progress_ = loading_progress; | |
| 47 } | |
| 48 | |
| 49 private: | |
| 50 double loading_progress_; | |
| 51 | |
| 52 DISALLOW_COPY_AND_ASSIGN(ToolbarTestWebState); | |
| 53 }; | |
| 54 | |
| 55 class ToolbarTestNavigationManager : public web::TestNavigationManager { | |
| 56 public: | |
| 57 ToolbarTestNavigationManager() | |
| 58 : can_go_back_(false), can_go_forward_(false) {} | |
| 59 | |
| 60 bool CanGoBack() const override { return can_go_back_; } | |
| 61 bool CanGoForward() const override { return can_go_forward_; } | |
| 62 | |
| 63 void set_can_go_back(bool can_go_back) { can_go_back_ = can_go_back; } | |
| 64 void set_can_go_forward(bool can_go_forward) { | |
| 65 can_go_forward_ = can_go_forward; | |
| 66 } | |
| 67 | |
| 68 private: | |
| 69 bool can_go_back_; | |
| 70 bool can_go_forward_; | |
| 71 }; | |
| 72 | |
| 73 } // namespace | |
| 74 | |
| 75 class ToolbarModelImplIOSTest : public PlatformTest { | 39 class ToolbarModelImplIOSTest : public PlatformTest { |
| 76 protected: | 40 protected: |
| 77 void SetUp() override { | 41 void SetUp() override { |
| 78 TestChromeBrowserState::Builder test_cbs_builder; | 42 TestChromeBrowserState::Builder test_cbs_builder; |
| 79 chrome_browser_state_ = test_cbs_builder.Build(); | 43 chrome_browser_state_ = test_cbs_builder.Build(); |
| 80 chrome_browser_state_->CreateBookmarkModel(true); | 44 chrome_browser_state_->CreateBookmarkModel(true); |
| 81 bookmarks::test::WaitForBookmarkModelToLoad( | 45 bookmarks::test::WaitForBookmarkModelToLoad( |
| 82 ios::BookmarkModelFactory::GetForBrowserState( | 46 ios::BookmarkModelFactory::GetForBrowserState( |
| 83 chrome_browser_state_.get())); | 47 chrome_browser_state_.get())); |
| 84 | 48 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 base::UTF8ToUTF16(kWebUrl), GURL(kWebUrl)); | 157 base::UTF8ToUTF16(kWebUrl), GURL(kWebUrl)); |
| 194 EXPECT_TRUE(toolbarModel_->IsCurrentTabBookmarked()); | 158 EXPECT_TRUE(toolbarModel_->IsCurrentTabBookmarked()); |
| 195 | 159 |
| 196 // Remove the bookmark and verify the toolbar model indicates that the URL is | 160 // Remove the bookmark and verify the toolbar model indicates that the URL is |
| 197 // not bookmarked. | 161 // not bookmarked. |
| 198 bookmark_model->Remove(node); | 162 bookmark_model->Remove(node); |
| 199 EXPECT_FALSE(toolbarModel_->IsCurrentTabBookmarked()); | 163 EXPECT_FALSE(toolbarModel_->IsCurrentTabBookmarked()); |
| 200 } | 164 } |
| 201 | 165 |
| 202 } // namespace | 166 } // namespace |
| OLD | NEW |