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

Side by Side Diff: ios/chrome/browser/ui/toolbar/toolbar_model_impl_ios_unittest.mm

Issue 2775623002: [ios] WebStateList owns all WebState it manages. (Closed)
Patch Set: Fix gn check Created 3 years, 8 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 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"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 void SetUp() override { 77 void SetUp() override {
78 TestChromeBrowserState::Builder test_cbs_builder; 78 TestChromeBrowserState::Builder test_cbs_builder;
79 chrome_browser_state_ = test_cbs_builder.Build(); 79 chrome_browser_state_ = test_cbs_builder.Build();
80 chrome_browser_state_->CreateBookmarkModel(true); 80 chrome_browser_state_->CreateBookmarkModel(true);
81 bookmarks::test::WaitForBookmarkModelToLoad( 81 bookmarks::test::WaitForBookmarkModelToLoad(
82 ios::BookmarkModelFactory::GetForBrowserState( 82 ios::BookmarkModelFactory::GetForBrowserState(
83 chrome_browser_state_.get())); 83 chrome_browser_state_.get()));
84 84
85 // Create a WebStateList that will always return the test WebState as 85 // Create a WebStateList that will always return the test WebState as
86 // the active WebState. 86 // the active WebState.
87 web_state_list_ = base::MakeUnique<WebStateList>( 87 web_state_list_ = base::MakeUnique<WebStateList>(&web_state_list_delegate_);
88 &web_state_list_delegate_, WebStateList::WebStateOwned);
89 std::unique_ptr<ToolbarTestWebState> web_state = 88 std::unique_ptr<ToolbarTestWebState> web_state =
90 base::MakeUnique<ToolbarTestWebState>(); 89 base::MakeUnique<ToolbarTestWebState>();
91 web_state->SetBrowserState(chrome_browser_state_.get()); 90 web_state->SetBrowserState(chrome_browser_state_.get());
92 web_state_ = web_state.get(); 91 web_state_ = web_state.get();
93 web_state_list_->InsertWebState(0, web_state.release()); 92 web_state_list_->InsertWebState(0, std::move(web_state));
94 web_state_list_->ActivateWebStateAt(0); 93 web_state_list_->ActivateWebStateAt(0);
95 94
96 toolbarModelDelegate_.reset( 95 toolbarModelDelegate_.reset(
97 new ToolbarModelDelegateIOS(web_state_list_.get())); 96 new ToolbarModelDelegateIOS(web_state_list_.get()));
98 toolbarModel_.reset(new ToolbarModelImplIOS(toolbarModelDelegate_.get())); 97 toolbarModel_.reset(new ToolbarModelImplIOS(toolbarModelDelegate_.get()));
99 } 98 }
100 99
101 web::TestWebThreadBundle thread_bundle_; 100 web::TestWebThreadBundle thread_bundle_;
102 std::unique_ptr<TestChromeBrowserState> chrome_browser_state_; 101 std::unique_ptr<TestChromeBrowserState> chrome_browser_state_;
103 FakeWebStateListDelegate web_state_list_delegate_; 102 FakeWebStateListDelegate web_state_list_delegate_;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 base::UTF8ToUTF16(kWebUrl), GURL(kWebUrl)); 193 base::UTF8ToUTF16(kWebUrl), GURL(kWebUrl));
195 EXPECT_TRUE(toolbarModel_->IsCurrentTabBookmarked()); 194 EXPECT_TRUE(toolbarModel_->IsCurrentTabBookmarked());
196 195
197 // Remove the bookmark and verify the toolbar model indicates that the URL is 196 // Remove the bookmark and verify the toolbar model indicates that the URL is
198 // not bookmarked. 197 // not bookmarked.
199 bookmark_model->Remove(node); 198 bookmark_model->Remove(node);
200 EXPECT_FALSE(toolbarModel_->IsCurrentTabBookmarked()); 199 EXPECT_FALSE(toolbarModel_->IsCurrentTabBookmarked());
201 } 200 }
202 201
203 } // namespace 202 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698