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

Side by Side Diff: ios/chrome/browser/tabs/tab_model_unittest.mm

Issue 2640093004: WebStateList is an array of web::WebState* wrappers. (Closed)
Patch Set: Fix leaks (caught by unit tests). Created 3 years, 11 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
« no previous file with comments | « ios/chrome/browser/tabs/tab_model.mm ('k') | ios/shared/chrome/browser/tabs/BUILD.gn » ('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 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 <objc/runtime.h> 5 #import <objc/runtime.h>
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/mac/scoped_nsautorelease_pool.h" 8 #include "base/mac/scoped_nsautorelease_pool.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 EXPECT_TRUE([tab parentTabModel] == nil); 831 EXPECT_TRUE([tab parentTabModel] == nil);
832 [tab_model_ insertTab:tab atIndex:0]; 832 [tab_model_ insertTab:tab atIndex:0];
833 [tab setParentTabModel:tab_model_.get()]; 833 [tab setParentTabModel:tab_model_.get()];
834 EXPECT_FALSE([tab parentTabModel] == nil); 834 EXPECT_FALSE([tab parentTabModel] == nil);
835 [tab_model_ closeTabAtIndex:0]; 835 [tab_model_ closeTabAtIndex:0];
836 } 836 }
837 837
838 TEST_F(TabModelTest, PersistSelectionChange) { 838 TEST_F(TabModelTest, PersistSelectionChange) {
839 TestChromeBrowserState::Builder test_cbs_builder; 839 TestChromeBrowserState::Builder test_cbs_builder;
840 auto chrome_browser_state = test_cbs_builder.Build(); 840 auto chrome_browser_state = test_cbs_builder.Build();
841 base::mac::ScopedNSAutoreleasePool pool;
841 842
842 NSString* stashPath = 843 NSString* stashPath =
843 base::SysUTF8ToNSString(chrome_browser_state->GetStatePath().value()); 844 base::SysUTF8ToNSString(chrome_browser_state->GetStatePath().value());
844 845
845 base::scoped_nsobject<TabModel> model([[TabModel alloc] 846 base::scoped_nsobject<TabModel> model([[TabModel alloc]
846 initWithSessionWindow:session_window_.get() 847 initWithSessionWindow:session_window_.get()
847 sessionService:[SessionServiceIOS sharedService] 848 sessionService:[SessionServiceIOS sharedService]
848 browserState:chrome_browser_state.get()]); 849 browserState:chrome_browser_state.get()]);
849 850
850 [model addTabWithURL:kURL referrer:kReferrer windowName:@"window 1"]; 851 [model addTabWithURL:kURL referrer:kReferrer windowName:@"window 1"];
(...skipping 17 matching lines...) Expand all
868 // Create tab model from saved session. 869 // Create tab model from saved session.
869 base::scoped_nsobject<TestSessionService> test_service( 870 base::scoped_nsobject<TestSessionService> test_service(
870 [[TestSessionService alloc] init]); 871 [[TestSessionService alloc] init]);
871 872
872 model.reset([[TabModel alloc] 873 model.reset([[TabModel alloc]
873 initWithSessionWindow:sessionWindow 874 initWithSessionWindow:sessionWindow
874 sessionService:test_service 875 sessionService:test_service
875 browserState:chrome_browser_state.get()]); 876 browserState:chrome_browser_state.get()]);
876 EXPECT_EQ(model.get().currentTab, [model tabAtIndex:1]); 877 EXPECT_EQ(model.get().currentTab, [model tabAtIndex:1]);
877 [model browserStateDestroyed]; 878 [model browserStateDestroyed];
879 model.reset();
878 880
879 // Clean up. 881 // Clean up.
880 EXPECT_TRUE([[NSFileManager defaultManager] removeItemAtPath:stashPath 882 EXPECT_TRUE([[NSFileManager defaultManager] removeItemAtPath:stashPath
881 error:nullptr]); 883 error:nullptr]);
882 } 884 }
883 885
884 } // anonymous namespace 886 } // anonymous namespace
OLDNEW
« no previous file with comments | « ios/chrome/browser/tabs/tab_model.mm ('k') | ios/shared/chrome/browser/tabs/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698