OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "ios/shared/chrome/browser/tabs/web_state_list_fast_enumeration_helper.h
" | 5 #import "ios/shared/chrome/browser/tabs/web_state_list_fast_enumeration_helper.h
" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #import "ios/shared/chrome/browser/tabs/fake_web_state_list_delegate.h" | 9 #import "ios/shared/chrome/browser/tabs/fake_web_state_list_delegate.h" |
10 #import "ios/shared/chrome/browser/tabs/web_state_list.h" | 10 #import "ios/shared/chrome/browser/tabs/web_state_list.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 } | 62 } |
63 return [array copy]; | 63 return [array copy]; |
64 } | 64 } |
65 | 65 |
66 void InsertTestWebStateForURLs(const char* const* urls, size_t count) { | 66 void InsertTestWebStateForURLs(const char* const* urls, size_t count) { |
67 for (size_t index = 0; index < count; ++index) { | 67 for (size_t index = 0; index < count; ++index) { |
68 auto test_web_state = base::MakeUnique<web::TestWebState>(); | 68 auto test_web_state = base::MakeUnique<web::TestWebState>(); |
69 test_web_state->SetCurrentURL(GURL(urls[index])); | 69 test_web_state->SetCurrentURL(GURL(urls[index])); |
70 | 70 |
71 web_state_list_.InsertWebState(web_state_list_.count(), | 71 web_state_list_.InsertWebState(web_state_list_.count(), |
72 test_web_state.release(), nullptr); | 72 test_web_state.release()); |
73 } | 73 } |
74 } | 74 } |
75 | 75 |
76 private: | 76 private: |
77 FakeWebStateListDelegate web_state_list_delegate_; | 77 FakeWebStateListDelegate web_state_list_delegate_; |
78 WebStateList web_state_list_; | 78 WebStateList web_state_list_; |
79 | 79 |
80 DISALLOW_COPY_AND_ASSIGN(WebStateListFastEnumerationHelperTest); | 80 DISALLOW_COPY_AND_ASSIGN(WebStateListFastEnumerationHelperTest); |
81 }; | 81 }; |
82 | 82 |
(...skipping 10 matching lines...) Expand all Loading... |
93 EXPECT_NSEQ([NSURL URLWithString:@(kURLs[index])], array[index]); | 93 EXPECT_NSEQ([NSURL URLWithString:@(kURLs[index])], array[index]); |
94 } | 94 } |
95 } | 95 } |
96 | 96 |
97 TEST_F(WebStateListFastEnumerationHelperTest, NilWrapper) { | 97 TEST_F(WebStateListFastEnumerationHelperTest, NilWrapper) { |
98 const char* const urls[] = {""}; | 98 const char* const urls[] = {""}; |
99 InsertTestWebStateForURLs(urls, arraysize(urls)); | 99 InsertTestWebStateForURLs(urls, arraysize(urls)); |
100 NSArray* array = ArrayFromWebStateList(); | 100 NSArray* array = ArrayFromWebStateList(); |
101 ASSERT_EQ(0u, [array count]); | 101 ASSERT_EQ(0u, [array count]); |
102 } | 102 } |
OLD | NEW |