| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/web/test/web_int_test.h" | 5 #import "ios/web/test/web_int_test.h" |
| 6 | 6 |
| 7 #import "base/ios/block_types.h" | 7 #import "base/ios/block_types.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #import "base/test/ios/wait_util.h" | 9 #import "base/test/ios/wait_util.h" |
| 10 #import "ios/web/public/test/http_server/http_server.h" | 10 #import "ios/web/public/test/http_server/http_server.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 GURL expected_url_; | 43 GURL expected_url_; |
| 44 bool page_loaded_; | 44 bool page_loaded_; |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 #pragma mark - WebIntTest | 47 #pragma mark - WebIntTest |
| 48 | 48 |
| 49 WebIntTest::WebIntTest() {} | 49 WebIntTest::WebIntTest() {} |
| 50 WebIntTest::~WebIntTest() {} | 50 WebIntTest::~WebIntTest() {} |
| 51 | 51 |
| 52 void WebIntTest::SetUp() { | 52 void WebIntTest::SetUp() { |
| 53 rootPool_ = [[NSAutoreleasePool alloc] init]; |
| 53 WebTest::SetUp(); | 54 WebTest::SetUp(); |
| 54 | 55 |
| 55 // Start the http server. | 56 // Start the http server. |
| 56 web::test::HttpServer& server = web::test::HttpServer::GetSharedInstance(); | 57 web::test::HttpServer& server = web::test::HttpServer::GetSharedInstance(); |
| 57 ASSERT_FALSE(server.IsRunning()); | 58 ASSERT_FALSE(server.IsRunning()); |
| 58 server.StartOrDie(); | 59 server.StartOrDie(); |
| 59 | 60 |
| 60 // Remove any previously existing WKWebView data. | 61 // Remove any previously existing WKWebView data. |
| 61 RemoveWKWebViewCreatedData([WKWebsiteDataStore defaultDataStore], | 62 RemoveWKWebViewCreatedData([WKWebsiteDataStore defaultDataStore], |
| 62 [WKWebsiteDataStore allWebsiteDataTypes]); | 63 [WKWebsiteDataStore allWebsiteDataTypes]); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 77 | 78 |
| 78 void WebIntTest::TearDown() { | 79 void WebIntTest::TearDown() { |
| 79 RemoveWKWebViewCreatedData([WKWebsiteDataStore defaultDataStore], | 80 RemoveWKWebViewCreatedData([WKWebsiteDataStore defaultDataStore], |
| 80 [WKWebsiteDataStore allWebsiteDataTypes]); | 81 [WKWebsiteDataStore allWebsiteDataTypes]); |
| 81 | 82 |
| 82 web::test::HttpServer& server = web::test::HttpServer::GetSharedInstance(); | 83 web::test::HttpServer& server = web::test::HttpServer::GetSharedInstance(); |
| 83 server.Stop(); | 84 server.Stop(); |
| 84 EXPECT_FALSE(server.IsRunning()); | 85 EXPECT_FALSE(server.IsRunning()); |
| 85 | 86 |
| 86 WebTest::TearDown(); | 87 WebTest::TearDown(); |
| 88 [rootPool_ release]; |
| 89 rootPool_ = nil; |
| 87 } | 90 } |
| 88 | 91 |
| 89 id WebIntTest::ExecuteJavaScript(NSString* script) { | 92 id WebIntTest::ExecuteJavaScript(NSString* script) { |
| 90 return web::ExecuteJavaScript(web_state()->GetJSInjectionReceiver(), script); | 93 return web::ExecuteJavaScript(web_state()->GetJSInjectionReceiver(), script); |
| 91 } | 94 } |
| 92 | 95 |
| 93 void WebIntTest::ExecuteBlockAndWaitForLoad(const GURL& url, | 96 void WebIntTest::ExecuteBlockAndWaitForLoad(const GURL& url, |
| 94 ProceduralBlock block) { | 97 ProceduralBlock block) { |
| 95 DCHECK(block); | 98 DCHECK(block); |
| 96 observer_ = base::MakeUnique<IntTestWebStateObserver>(web_state()); | 99 observer_ = base::MakeUnique<IntTestWebStateObserver>(web_state()); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 NSInteger WebIntTest::GetIndexOfNavigationItem( | 155 NSInteger WebIntTest::GetIndexOfNavigationItem( |
| 153 const web::NavigationItem* item) { | 156 const web::NavigationItem* item) { |
| 154 for (NSInteger i = 0; i < navigation_manager()->GetItemCount(); ++i) { | 157 for (NSInteger i = 0; i < navigation_manager()->GetItemCount(); ++i) { |
| 155 if (navigation_manager()->GetItemAtIndex(i) == item) | 158 if (navigation_manager()->GetItemAtIndex(i) == item) |
| 156 return i; | 159 return i; |
| 157 } | 160 } |
| 158 return NSNotFound; | 161 return NSNotFound; |
| 159 } | 162 } |
| 160 | 163 |
| 161 } // namespace web | 164 } // namespace web |
| OLD | NEW |