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

Unified Diff: ios/web/web_state/ui/wk_back_forward_list_item_holder_unittest.mm

Issue 2933363002: [ObjC ARC] Converts ios/web:ios_web_web_state_ui_unittests to ARC. (Closed)
Patch Set: Review nits. Created 3 years, 6 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/web/web_state/ui/wk_back_forward_list_item_holder_unittest.mm
diff --git a/ios/web/web_state/ui/wk_back_forward_list_item_holder_unittest.mm b/ios/web/web_state/ui/wk_back_forward_list_item_holder_unittest.mm
index 5d31e245737b31db9132a6c4c2c9afb4ea00fe16..48c1465748828d59309027bd191c8dd0eafea322 100644
--- a/ios/web/web_state/ui/wk_back_forward_list_item_holder_unittest.mm
+++ b/ios/web/web_state/ui/wk_back_forward_list_item_holder_unittest.mm
@@ -12,6 +12,10 @@
#import "testing/gtest_mac.h"
#include "testing/platform_test.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
namespace web {
// Test fixture for WKBackForwardListItemHolder class.
@@ -50,11 +54,11 @@ TEST_F(WKBackForwardListItemHolderTest, GetHolderFromDifferentNavigationItem) {
// directly and will crash.
TEST_F(WKBackForwardListItemHolderTest, GetBackForwardListItemFromHolder) {
std::unique_ptr<web::NavigationItem> item(NavigationItem::Create());
- base::scoped_nsobject<NSObject> input([[NSObject alloc] init]);
+ NSObject* input = [[NSObject alloc] init];
WKBackForwardListItemHolder* holder =
WKBackForwardListItemHolder::FromNavigationItem(item.get());
holder->set_back_forward_list_item(
- static_cast<WKBackForwardListItem*>(input.get()));
+ static_cast<WKBackForwardListItem*>(input));
NSObject* result = holder->back_forward_list_item();
EXPECT_EQ(input, result);
}
@@ -102,28 +106,4 @@ TEST_F(WKBackForwardListItemHolderTest, GetNavigationTypeFromHolder) {
EXPECT_EQ(type, holder->navigation_type());
}
-// Tests that |back_forward_list_item| returns nil if the internal
-// WKBackForwardListItem was deallocated. The test bellow uses NSObject
-// instead of WKBackForwardListItem because WKBackForwardListItem alloc/
-// release is not designed to be called directly and will crash.
-TEST_F(WKBackForwardListItemHolderTest, GetNilBackForwardListItemFromHolder) {
- std::unique_ptr<web::NavigationItem> item(NavigationItem::Create());
- WKBackForwardListItemHolder* holder =
- WKBackForwardListItemHolder::FromNavigationItem(item.get());
-
- // Add a WKBackForwardListItem and verify that |back_forward_list_item|
- // returns does not return nil.
- base::scoped_nsobject<NSObject> input([[NSObject alloc] init]);
- holder->set_back_forward_list_item(
- static_cast<WKBackForwardListItem*>(input.get()));
- NSObject* result = holder->back_forward_list_item();
- EXPECT_NE(nil, result);
-
- // Deallocate the WKBackForwardListItem and verify that
- // |back_forward_list_item| returns nil.
- input.reset();
- result = holder->back_forward_list_item();
- EXPECT_EQ(nil, result);
-}
-
} // namespace web

Powered by Google App Engine
This is Rietveld 408576698