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

Unified Diff: ios/shared/chrome/browser/tabs/web_state_list_fast_enumeration_helper_unittest.mm

Issue 2799723002: [ios] Move WebStateList to ios/chrome/browser/web_state_list. (Closed)
Patch Set: Rebase. 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 side-by-side diff with in-line comments
Download patch
Index: ios/shared/chrome/browser/tabs/web_state_list_fast_enumeration_helper_unittest.mm
diff --git a/ios/shared/chrome/browser/tabs/web_state_list_fast_enumeration_helper_unittest.mm b/ios/shared/chrome/browser/tabs/web_state_list_fast_enumeration_helper_unittest.mm
deleted file mode 100644
index 8d47f01ba703a1b9075e7ce373e13511606f5229..0000000000000000000000000000000000000000
--- a/ios/shared/chrome/browser/tabs/web_state_list_fast_enumeration_helper_unittest.mm
+++ /dev/null
@@ -1,101 +0,0 @@
-// Copyright 2017 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#import "ios/shared/chrome/browser/tabs/web_state_list_fast_enumeration_helper.h"
-
-#include "base/macros.h"
-#include "base/memory/ptr_util.h"
-#import "ios/shared/chrome/browser/tabs/fake_web_state_list_delegate.h"
-#import "ios/shared/chrome/browser/tabs/web_state_list.h"
-#import "ios/web/public/test/fakes/test_web_state.h"
-#import "net/base/mac/url_conversions.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "testing/gtest_mac.h"
-#include "testing/platform_test.h"
-#include "url/gurl.h"
-
-#if !defined(__has_feature) || !__has_feature(objc_arc)
-#error "This file requires ARC support."
-#endif
-
-namespace {
-const char kURL0[] = "https://chromium.org/0";
-const char kURL1[] = "https://chromium.org/1";
-const char kURL2[] = "https://chromium.org/2";
-const char* const kURLs[] = {kURL0, kURL1, kURL2};
-} // namespace
-
-@interface WebStateProxyFactoryForWebStateListFastEnumerationHelperTest
- : NSObject<WebStateProxyFactory>
-@end
-
-@implementation WebStateProxyFactoryForWebStateListFastEnumerationHelperTest
-
-- (id)proxyForWebState:(web::WebState*)webState {
- return net::NSURLWithGURL(webState->GetVisibleURL());
-}
-
-@end
-
-class WebStateListFastEnumerationHelperTest : public PlatformTest {
- public:
- WebStateListFastEnumerationHelperTest()
- : web_state_list_(&web_state_list_delegate_) {}
-
- NSArray* ArrayFromWebStateList() {
- id<WebStateProxyFactory> proxy =
- [[WebStateProxyFactoryForWebStateListFastEnumerationHelperTest alloc]
- init];
- WebStateListFastEnumerationHelper* helper =
- [[WebStateListFastEnumerationHelper alloc]
- initWithWebStateList:&web_state_list_
- proxyFactory:proxy];
- NSMutableArray* array = [NSMutableArray array];
- for (id wrapper in helper) {
- // NSArray* cannot store a nil pointer. The NSFastEnumeration protocol
- // allows returning nil as one of the value in the iterated container,
- // so skip the value in that case (see NilWrapper test).
- if (wrapper)
- [array addObject:wrapper];
- }
- return [array copy];
- }
-
- void InsertTestWebStateForURLs(const char* const* urls, size_t count) {
- for (size_t index = 0; index < count; ++index) {
- auto test_web_state = base::MakeUnique<web::TestWebState>();
- test_web_state->SetCurrentURL(GURL(urls[index]));
-
- web_state_list_.InsertWebState(web_state_list_.count(),
- std::move(test_web_state));
- }
- }
-
- private:
- FakeWebStateListDelegate web_state_list_delegate_;
- WebStateList web_state_list_;
-
- DISALLOW_COPY_AND_ASSIGN(WebStateListFastEnumerationHelperTest);
-};
-
-TEST_F(WebStateListFastEnumerationHelperTest, Empty) {
- NSArray* array = ArrayFromWebStateList();
- EXPECT_EQ(0u, [array count]);
-}
-
-TEST_F(WebStateListFastEnumerationHelperTest, FastEnumeration) {
- InsertTestWebStateForURLs(kURLs, arraysize(kURLs));
- NSArray* array = ArrayFromWebStateList();
- ASSERT_EQ(arraysize(kURLs), [array count]);
- for (size_t index = 0; index < arraysize(kURLs); ++index) {
- EXPECT_NSEQ([NSURL URLWithString:@(kURLs[index])], array[index]);
- }
-}
-
-TEST_F(WebStateListFastEnumerationHelperTest, NilWrapper) {
- const char* const urls[] = {""};
- InsertTestWebStateForURLs(urls, arraysize(urls));
- NSArray* array = ArrayFromWebStateList();
- ASSERT_EQ(0u, [array count]);
-}

Powered by Google App Engine
This is Rietveld 408576698