| OLD | NEW | 
|    1 // Copyright 2016 The Chromium Authors. All rights reserved. |    1 // Copyright 2016 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 <EarlGrey/EarlGrey.h> |    5 #import <EarlGrey/EarlGrey.h> | 
|    6  |    6  | 
|    7 #include "base/memory/ptr_util.h" |    7 #include "base/memory/ptr_util.h" | 
|    8 #include "base/strings/stringprintf.h" |    8 #include "base/strings/stringprintf.h" | 
|    9 #include "base/time/time.h" |    9 #include "base/time/time.h" | 
|   10 #include "ios/chrome/browser/ui/ui_util.h" |   10 #include "ios/chrome/browser/ui/ui_util.h" | 
|   11 #include "ios/chrome/test/app/navigation_test_util.h" |   11 #include "ios/chrome/test/app/navigation_test_util.h" | 
 |   12 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" | 
|   12 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" |   13 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" | 
|   13 #import "ios/chrome/test/earl_grey/chrome_matchers.h" |   14 #import "ios/chrome/test/earl_grey/chrome_matchers.h" | 
|   14 #import "ios/chrome/test/earl_grey/chrome_test_case.h" |   15 #import "ios/chrome/test/earl_grey/chrome_test_case.h" | 
|   15 #include "ios/web/public/test/http_server/html_response_provider.h" |   16 #include "ios/web/public/test/http_server/html_response_provider.h" | 
|   16 #import "ios/web/public/test/http_server/http_server.h" |   17 #import "ios/web/public/test/http_server/http_server.h" | 
|   17 #include "ios/web/public/test/http_server/http_server_util.h" |   18 #include "ios/web/public/test/http_server/http_server_util.h" | 
|   18 #include "url/gurl.h" |   19 #include "url/gurl.h" | 
|   19  |   20  | 
|   20 #if !defined(__has_feature) || !__has_feature(objc_arc) |   21 #if !defined(__has_feature) || !__has_feature(objc_arc) | 
|   21 #error "This file requires ARC support." |   22 #error "This file requires ARC support." | 
|   22 #endif |   23 #endif | 
|   23  |   24  | 
|   24 using chrome_test_util::ButtonWithAccessibilityLabelId; |   25 using chrome_test_util::ButtonWithAccessibilityLabelId; | 
|   25 using chrome_test_util::WebViewContainingText; |  | 
|   26  |   26  | 
|   27 namespace { |   27 namespace { | 
|   28  |   28  | 
|   29 // Text appearing on the navigation test page. |   29 // Text appearing on the navigation test page. | 
|   30 const char kPageText[] = "Navigation testing page"; |   30 const char kPageText[] = "Navigation testing page"; | 
|   31  |   31  | 
|   32 // Response provider that serves the page which never finishes loading. |   32 // Response provider that serves the page which never finishes loading. | 
|   33 class InfinitePendingResponseProvider : public HtmlResponseProvider { |   33 class InfinitePendingResponseProvider : public HtmlResponseProvider { | 
|   34  public: |   34  public: | 
|   35   explicit InfinitePendingResponseProvider(const GURL& url) : url_(url) {} |   35   explicit InfinitePendingResponseProvider(const GURL& url) : url_(url) {} | 
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   99   if (IsIPadIdiom()) { |   99   if (IsIPadIdiom()) { | 
|  100     // Disable EG synchronization so the framework does not wait until the tab |  100     // Disable EG synchronization so the framework does not wait until the tab | 
|  101     // loading spinner becomes idle (which will not happen until the stop button |  101     // loading spinner becomes idle (which will not happen until the stop button | 
|  102     // is tapped). |  102     // is tapped). | 
|  103     [[GREYConfiguration sharedInstance] |  103     [[GREYConfiguration sharedInstance] | 
|  104             setValue:@NO |  104             setValue:@NO | 
|  105         forConfigKey:kGREYConfigKeySynchronizationEnabled]; |  105         forConfigKey:kGREYConfigKeySynchronizationEnabled]; | 
|  106   } |  106   } | 
|  107  |  107  | 
|  108   // Wait until the page is half loaded. |  108   // Wait until the page is half loaded. | 
|  109   [[EarlGrey selectElementWithMatcher:WebViewContainingText(kPageText)] |  109   [ChromeEarlGrey waitForWebViewContainingText:kPageText]; | 
|  110       assertWithMatcher:grey_notNil()]; |  | 
|  111  |  110  | 
|  112   // On iPhone Stop/Reload button is a part of tools menu, so open it. |  111   // On iPhone Stop/Reload button is a part of tools menu, so open it. | 
|  113   if (!IsIPadIdiom()) { |  112   if (!IsIPadIdiom()) { | 
|  114     [ChromeEarlGreyUI openToolsMenu]; |  113     [ChromeEarlGreyUI openToolsMenu]; | 
|  115   } |  114   } | 
|  116  |  115  | 
|  117   // Verify that stop button is visible and reload button is hidden. |  116   // Verify that stop button is visible and reload button is hidden. | 
|  118   [[EarlGrey selectElementWithMatcher:chrome_test_util::StopButton()] |  117   [[EarlGrey selectElementWithMatcher:chrome_test_util::StopButton()] | 
|  119       assertWithMatcher:grey_sufficientlyVisible()]; |  118       assertWithMatcher:grey_sufficientlyVisible()]; | 
|  120   [[EarlGrey selectElementWithMatcher:chrome_test_util::ReloadButton()] |  119   [[EarlGrey selectElementWithMatcher:chrome_test_util::ReloadButton()] | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
|  134   if (!IsIPadIdiom()) { |  133   if (!IsIPadIdiom()) { | 
|  135     [ChromeEarlGreyUI openToolsMenu]; |  134     [ChromeEarlGreyUI openToolsMenu]; | 
|  136   } |  135   } | 
|  137   [[EarlGrey selectElementWithMatcher:chrome_test_util::StopButton()] |  136   [[EarlGrey selectElementWithMatcher:chrome_test_util::StopButton()] | 
|  138       assertWithMatcher:grey_notVisible()]; |  137       assertWithMatcher:grey_notVisible()]; | 
|  139   [[EarlGrey selectElementWithMatcher:chrome_test_util::ReloadButton()] |  138   [[EarlGrey selectElementWithMatcher:chrome_test_util::ReloadButton()] | 
|  140       assertWithMatcher:grey_sufficientlyVisible()]; |  139       assertWithMatcher:grey_sufficientlyVisible()]; | 
|  141 } |  140 } | 
|  142  |  141  | 
|  143 @end |  142 @end | 
| OLD | NEW |