Commit 11da369f authored by Eugene But's avatar Eugene But Committed by Commit Bot

Modernize NavigationAndLoadCallbacksTest integration test.

Notable changes:

1.) Use C-functions helpers instead of WebIntTest method. This will
    allow to switch NavigationAndLoadCallbacksTest to a simpler base
    class in the future.
2.) Added test::WaitForPageToFinishLoading C-function, which can be
    used across multiple tests to wait for pageload.
3.) Removed extra usage of web:: because NavigationAndLoadCallbacksTest
    is already placed into web namespace.
4.) Removed web_state()->SetDelegate(nullptr); calls, because unlike
    WebIntTest, WebTestWithWebState does not set a web delegate.

Bug: None
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: If5f26f1da40a90fde6378964b0f29a6ac30c16bb
Reviewed-on: https://chromium-review.googlesource.com/1056203
Commit-Queue: Kurt Horimoto <kkhorimoto@chromium.org>
Reviewed-by: default avatarKurt Horimoto <kkhorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#558908}
parent cff515c1
......@@ -5,15 +5,12 @@
#include "ios/chrome/test/app/navigation_test_util.h"
#import "ios/chrome/test/app/chrome_test_util.h"
#import "ios/testing/wait_util.h"
#import "ios/web/public/test/navigation_test_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
using testing::WaitUntilConditionOrTimeout;
namespace chrome_test_util {
void LoadUrl(const GURL& url) {
......@@ -25,9 +22,7 @@ bool IsLoading() {
}
bool WaitForPageToFinishLoading() {
return WaitUntilConditionOrTimeout(testing::kWaitForPageLoadTimeout, ^{
return !IsLoading();
});
return web::test::WaitForPageToFinishLoading(GetCurrentWebState());
}
} // namespace chrome_test_util
......@@ -12,7 +12,11 @@ namespace web {
namespace test {
// Loads |url| in |web_state| with transition of type ui::PAGE_TRANSITION_TYPED.
void LoadUrl(web::WebState* web_state, const GURL& url);
void LoadUrl(WebState* web_state, const GURL& url);
// Returns true if the current page in the current WebState finishes loading
// within a timeout.
bool WaitForPageToFinishLoading(WebState* web_state) WARN_UNUSED_RESULT;
} // namespace test
} // namespace web
......
......@@ -4,13 +4,15 @@
#import "ios/web/public/test/navigation_test_util.h"
#import "ios/testing/wait_util.h"
#import "ios/web/public/navigation_manager.h"
#import "ios/web/public/web_state/web_state.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
using web::NavigationManager;
using testing::WaitUntilConditionOrTimeout;
namespace web {
namespace test {
......@@ -22,5 +24,11 @@ void LoadUrl(web::WebState* web_state, const GURL& url) {
navigation_manager->LoadURLWithParams(params);
}
bool WaitForPageToFinishLoading(WebState* web_state) {
return WaitUntilConditionOrTimeout(testing::kWaitForPageLoadTimeout, ^{
return !web_state->IsLoading();
});
}
} // namespace test
} // namespace web
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment