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

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

Issue 2678883002: Add a ScopedNSAutoreleasePool to TabModelTest.PersistSelectionChange (Closed)
Patch Set: Created 3 years, 10 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 | « no previous file | no next file » | 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 813 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 EXPECT_TRUE([tab parentTabModel] == nil); 824 EXPECT_TRUE([tab parentTabModel] == nil);
825 [tab_model_ insertTab:tab atIndex:0]; 825 [tab_model_ insertTab:tab atIndex:0];
826 [tab setParentTabModel:tab_model_.get()]; 826 [tab setParentTabModel:tab_model_.get()];
827 EXPECT_FALSE([tab parentTabModel] == nil); 827 EXPECT_FALSE([tab parentTabModel] == nil);
828 [tab_model_ closeTabAtIndex:0]; 828 [tab_model_ closeTabAtIndex:0];
829 } 829 }
830 830
831 TEST_F(TabModelTest, PersistSelectionChange) { 831 TEST_F(TabModelTest, PersistSelectionChange) {
832 TestChromeBrowserState::Builder test_cbs_builder; 832 TestChromeBrowserState::Builder test_cbs_builder;
833 auto chrome_browser_state = test_cbs_builder.Build(); 833 auto chrome_browser_state = test_cbs_builder.Build();
834 base::mac::ScopedNSAutoreleasePool pool;
rohitrao (ping after 24h) 2017/02/06 17:31:46 Can you please add a comment explaining why this p
sdefresne 2017/02/06 17:46:43 Done.
834 835
835 NSString* stashPath = 836 NSString* stashPath =
836 base::SysUTF8ToNSString(chrome_browser_state->GetStatePath().value()); 837 base::SysUTF8ToNSString(chrome_browser_state->GetStatePath().value());
837 838
838 base::scoped_nsobject<TabModel> model([[TabModel alloc] 839 base::scoped_nsobject<TabModel> model([[TabModel alloc]
839 initWithSessionWindow:session_window_.get() 840 initWithSessionWindow:session_window_.get()
840 sessionService:[SessionServiceIOS sharedService] 841 sessionService:[SessionServiceIOS sharedService]
841 browserState:chrome_browser_state.get()]); 842 browserState:chrome_browser_state.get()]);
842 843
843 [model addTabWithURL:kURL referrer:kReferrer windowName:@"window 1"]; 844 [model addTabWithURL:kURL referrer:kReferrer windowName:@"window 1"];
(...skipping 17 matching lines...) Expand all
861 // Create tab model from saved session. 862 // Create tab model from saved session.
862 base::scoped_nsobject<TestSessionService> test_service( 863 base::scoped_nsobject<TestSessionService> test_service(
863 [[TestSessionService alloc] init]); 864 [[TestSessionService alloc] init]);
864 865
865 model.reset([[TabModel alloc] 866 model.reset([[TabModel alloc]
866 initWithSessionWindow:sessionWindow 867 initWithSessionWindow:sessionWindow
867 sessionService:test_service 868 sessionService:test_service
868 browserState:chrome_browser_state.get()]); 869 browserState:chrome_browser_state.get()]);
869 EXPECT_EQ(model.get().currentTab, [model tabAtIndex:1]); 870 EXPECT_EQ(model.get().currentTab, [model tabAtIndex:1]);
870 [model browserStateDestroyed]; 871 [model browserStateDestroyed];
872 model.reset();
873 base::RunLoop().RunUntilIdle();
rohitrao (ping after 24h) 2017/02/06 17:31:46 Why is this necessary? Does this drain the pool?
sdefresne 2017/02/06 17:46:43 This is unrelated to draining the pool. It is the
871 874
872 // Clean up. 875 // Clean up.
873 EXPECT_TRUE([[NSFileManager defaultManager] removeItemAtPath:stashPath 876 EXPECT_TRUE([[NSFileManager defaultManager] removeItemAtPath:stashPath
874 error:nullptr]); 877 error:nullptr]);
875 } 878 }
876 879
877 } // anonymous namespace 880 } // anonymous namespace
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698