Commit 916138ba authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

DICE browsertests: fix usage of UrlLoadObserver

Just instantiating a UrlLoadObserver does nothing useful; you have to
actually call .Wait() on it.
It turns out that when waiting for an NTP load, the tests were trying to
verify the wrong thing: The load doesn't actually end up at
chrome://newtab, but at chrome-search://local-ntp/local-ntp.html.

Bug: none
Change-Id: I126d3a3ae2ce07c3424326a8c3c8eaecbc97491b
Reviewed-on: https://chromium-review.googlesource.com/1126299
Commit-Queue: Marc Treib <treib@chromium.org>
Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#573665}
parent 2072f043
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "chrome/browser/ui/webui/signin/login_ui_service.h" #include "chrome/browser/ui/webui/signin/login_ui_service.h"
#include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
#include "chrome/browser/ui/webui/signin/login_ui_test_utils.h" #include "chrome/browser/ui/webui/signin/login_ui_test_utils.h"
#include "chrome/common/url_constants.h"
#include "chrome/common/webui_url_constants.h" #include "chrome/common/webui_url_constants.h"
#include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h" #include "chrome/test/base/ui_test_utils.h"
...@@ -969,6 +970,10 @@ IN_PROC_BROWSER_TEST_F(DicePrepareMigrationBrowserTest, EnableSyncAfterToken) { ...@@ -969,6 +970,10 @@ IN_PROC_BROWSER_TEST_F(DicePrepareMigrationBrowserTest, EnableSyncAfterToken) {
GetDeviceId().c_str()), GetDeviceId().c_str()),
dice_request_header_); dice_request_header_);
ui_test_utils::UrlLoadObserver ntp_url_observer(
GURL(chrome::kChromeSearchLocalNtpUrl),
content::NotificationService::AllSources());
WaitForSigninSucceeded(); WaitForSigninSucceeded();
EXPECT_EQ(GetMainAccountID(), EXPECT_EQ(GetMainAccountID(),
GetSigninManager()->GetAuthenticatedAccountId()); GetSigninManager()->GetAuthenticatedAccountId());
...@@ -978,9 +983,7 @@ IN_PROC_BROWSER_TEST_F(DicePrepareMigrationBrowserTest, EnableSyncAfterToken) { ...@@ -978,9 +983,7 @@ IN_PROC_BROWSER_TEST_F(DicePrepareMigrationBrowserTest, EnableSyncAfterToken) {
EXPECT_EQ(1, reconcilor_started_count_); EXPECT_EQ(1, reconcilor_started_count_);
// Check that the tab was navigated to the NTP. // Check that the tab was navigated to the NTP.
ui_test_utils::UrlLoadObserver ntp_url_observer( ntp_url_observer.Wait();
GURL(chrome::kChromeUINewTabURL),
content::NotificationService::AllSources());
// Dismiss the Sync confirmation UI. // Dismiss the Sync confirmation UI.
EXPECT_TRUE(login_ui_test_utils::DismissSyncConfirmationDialog( EXPECT_TRUE(login_ui_test_utils::DismissSyncConfirmationDialog(
...@@ -992,6 +995,10 @@ IN_PROC_BROWSER_TEST_F(DicePrepareMigrationBrowserTest, EnableSyncAfterToken) { ...@@ -992,6 +995,10 @@ IN_PROC_BROWSER_TEST_F(DicePrepareMigrationBrowserTest, EnableSyncAfterToken) {
IN_PROC_BROWSER_TEST_F(DicePrepareMigrationBrowserTest, EnableSyncBeforeToken) { IN_PROC_BROWSER_TEST_F(DicePrepareMigrationBrowserTest, EnableSyncBeforeToken) {
EXPECT_EQ(0, reconcilor_started_count_); EXPECT_EQ(0, reconcilor_started_count_);
ui_test_utils::UrlLoadObserver enable_sync_url_observer(
https_server_.GetURL(kEnableSyncURL),
content::NotificationService::AllSources());
// Signin using the Chrome Sync endpoint. // Signin using the Chrome Sync endpoint.
browser()->signin_view_controller()->ShowSignin( browser()->signin_view_controller()->ShowSignin(
profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN, browser(), profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN, browser(),
...@@ -1000,9 +1007,7 @@ IN_PROC_BROWSER_TEST_F(DicePrepareMigrationBrowserTest, EnableSyncBeforeToken) { ...@@ -1000,9 +1007,7 @@ IN_PROC_BROWSER_TEST_F(DicePrepareMigrationBrowserTest, EnableSyncBeforeToken) {
// Receive ENABLE_SYNC. // Receive ENABLE_SYNC.
SendEnableSyncResponse(); SendEnableSyncResponse();
// Wait for the page to be fully loaded. // Wait for the page to be fully loaded.
ui_test_utils::UrlLoadObserver enable_sync_url_observer( enable_sync_url_observer.Wait();
https_server_.GetURL(kEnableSyncURL),
content::NotificationService::AllSources());
// Receive token. // Receive token.
EXPECT_FALSE(GetTokenService()->RefreshTokenIsAvailable(GetMainAccountID())); EXPECT_FALSE(GetTokenService()->RefreshTokenIsAvailable(GetMainAccountID()));
...@@ -1018,6 +1023,10 @@ IN_PROC_BROWSER_TEST_F(DicePrepareMigrationBrowserTest, EnableSyncBeforeToken) { ...@@ -1018,6 +1023,10 @@ IN_PROC_BROWSER_TEST_F(DicePrepareMigrationBrowserTest, EnableSyncBeforeToken) {
GetDeviceId().c_str()), GetDeviceId().c_str()),
dice_request_header_); dice_request_header_);
ui_test_utils::UrlLoadObserver ntp_url_observer(
GURL(chrome::kChromeSearchLocalNtpUrl),
content::NotificationService::AllSources());
WaitForSigninSucceeded(); WaitForSigninSucceeded();
EXPECT_EQ(GetMainAccountID(), EXPECT_EQ(GetMainAccountID(),
GetSigninManager()->GetAuthenticatedAccountId()); GetSigninManager()->GetAuthenticatedAccountId());
...@@ -1027,9 +1036,7 @@ IN_PROC_BROWSER_TEST_F(DicePrepareMigrationBrowserTest, EnableSyncBeforeToken) { ...@@ -1027,9 +1036,7 @@ IN_PROC_BROWSER_TEST_F(DicePrepareMigrationBrowserTest, EnableSyncBeforeToken) {
EXPECT_EQ(1, reconcilor_started_count_); EXPECT_EQ(1, reconcilor_started_count_);
// Check that the tab was navigated to the NTP. // Check that the tab was navigated to the NTP.
ui_test_utils::UrlLoadObserver ntp_url_observer( ntp_url_observer.Wait();
GURL(chrome::kChromeUINewTabURL),
content::NotificationService::AllSources());
// Dismiss the Sync confirmation UI. // Dismiss the Sync confirmation UI.
EXPECT_TRUE(login_ui_test_utils::DismissSyncConfirmationDialog( EXPECT_TRUE(login_ui_test_utils::DismissSyncConfirmationDialog(
......
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