Index: ios/web_view/test/chrome_web_view_restorable_state_inttest.mm |
diff --git a/ios/web_view/test/chrome_web_view_restorable_state_inttest.mm b/ios/web_view/test/chrome_web_view_restorable_state_inttest.mm |
index 7c17e25bbe198231e4ab8e0a6a7b39116e282ff1..47af93fb0388f37c839bef4bdaeb0b21a64d15c0 100644 |
--- a/ios/web_view/test/chrome_web_view_restorable_state_inttest.mm |
+++ b/ios/web_view/test/chrome_web_view_restorable_state_inttest.mm |
@@ -5,20 +5,16 @@ |
#import <ChromeWebView/ChromeWebView.h> |
#import "ios/web_view/test/chrome_web_view_test.h" |
+#import "ios/web_view/test/web_view_test_util.h" |
#include "testing/gtest_mac.h" |
#if !defined(__has_feature) || !__has_feature(objc_arc) |
#error "This file requires ARC support." |
#endif |
-namespace { |
+namespace ios_web_view { |
-// Creates web view for testing. |
-CWVWebView* CreateWebView() { |
- return [[CWVWebView alloc] |
- initWithFrame:CGRectMake(0, 0, 50, 50) |
- configuration:[CWVWebViewConfiguration defaultConfiguration]]; |
-} |
+namespace { |
// Creates a new web view and restores its state from |source_web_view|. |
CWVWebView* CreateWebViewWithState(CWVWebView* source_web_view) { |
@@ -29,45 +25,40 @@ CWVWebView* CreateWebViewWithState(CWVWebView* source_web_view) { |
[archiver finishEncoding]; |
NSKeyedUnarchiver* unarchiver = |
[[NSKeyedUnarchiver alloc] initForReadingWithData:data]; |
- CWVWebView* result = CreateWebView(); |
+ CWVWebView* result = test::CreateWebView(); |
[result decodeRestorableStateWithCoder:unarchiver]; |
return result; |
} |
} // namespace |
-namespace ios_web_view { |
- |
// Tests encodeRestorableStateWithCoder: and decodeRestorableStateWithCoder: |
// methods. |
typedef ios_web_view::ChromeWebViewTest ChromeWebViewRestorableStateTest; |
TEST_F(ChromeWebViewRestorableStateTest, EncodeDecode) { |
- // Create web view that will be used as a source for state restoration. |
- CWVWebView* web_view = CreateWebView(); |
- |
// Load 2 URLs to create non-default state. |
- ASSERT_FALSE(web_view.lastCommittedURL); |
- ASSERT_FALSE(web_view.visibleURL); |
- ASSERT_FALSE(web_view.canGoBack); |
- ASSERT_FALSE(web_view.canGoForward); |
- LoadUrl(web_view, [NSURL URLWithString:@"about:newtab"]); |
- ASSERT_NSEQ(@"about:newtab", web_view.lastCommittedURL.absoluteString); |
- ASSERT_NSEQ(@"about:newtab", web_view.visibleURL.absoluteString); |
- LoadUrl(web_view, [NSURL URLWithString:@"about:blank"]); |
- ASSERT_NSEQ(@"about:blank", web_view.lastCommittedURL.absoluteString); |
- ASSERT_NSEQ(@"about:blank", web_view.visibleURL.absoluteString); |
- ASSERT_TRUE(web_view.canGoBack); |
- ASSERT_FALSE(web_view.canGoForward); |
+ ASSERT_FALSE([web_view_ lastCommittedURL]); |
+ ASSERT_FALSE([web_view_ visibleURL]); |
+ ASSERT_FALSE([web_view_ canGoBack]); |
+ ASSERT_FALSE([web_view_ canGoForward]); |
+ LoadUrl(web_view_, [NSURL URLWithString:@"about:newtab"]); |
+ ASSERT_NSEQ(@"about:newtab", [web_view_ lastCommittedURL].absoluteString); |
+ ASSERT_NSEQ(@"about:newtab", [web_view_ visibleURL].absoluteString); |
+ LoadUrl(web_view_, [NSURL URLWithString:@"about:blank"]); |
+ ASSERT_NSEQ(@"about:blank", [web_view_ lastCommittedURL].absoluteString); |
+ ASSERT_NSEQ(@"about:blank", [web_view_ visibleURL].absoluteString); |
+ ASSERT_TRUE([web_view_ canGoBack]); |
+ ASSERT_FALSE([web_view_ canGoForward]); |
// Create second web view and restore its state from the first web view. |
- CWVWebView* restored_web_view = CreateWebViewWithState(web_view); |
+ CWVWebView* restored_web_view = CreateWebViewWithState(web_view_); |
// Verify that the state has been restored correctly. |
EXPECT_NSEQ(@"about:blank", |
- restored_web_view.lastCommittedURL.absoluteString); |
- EXPECT_NSEQ(@"about:blank", restored_web_view.visibleURL.absoluteString); |
- EXPECT_TRUE(web_view.canGoBack); |
- EXPECT_FALSE(web_view.canGoForward); |
+ [restored_web_view lastCommittedURL].absoluteString); |
+ EXPECT_NSEQ(@"about:blank", [restored_web_view visibleURL].absoluteString); |
+ EXPECT_TRUE([web_view_ canGoBack]); |
+ EXPECT_FALSE([web_view_ canGoForward]); |
} |
} // namespace ios_web_view |