| 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/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 11 #include "ios/chrome/browser/ui/ui_util.h" | 11 #include "ios/chrome/browser/ui/ui_util.h" |
| 12 #include "ios/chrome/test/app/navigation_test_util.h" | 12 #include "ios/chrome/test/app/navigation_test_util.h" |
| 13 #include "ios/chrome/test/app/web_view_interaction_test_util.h" | 13 #include "ios/chrome/test/app/web_view_interaction_test_util.h" |
| 14 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" | 14 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" |
| 15 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" | 15 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" |
| 16 #import "ios/chrome/test/earl_grey/chrome_matchers.h" | 16 #import "ios/chrome/test/earl_grey/chrome_matchers.h" |
| 17 #import "ios/chrome/test/earl_grey/chrome_test_case.h" | 17 #import "ios/chrome/test/earl_grey/chrome_test_case.h" |
| 18 #import "ios/third_party/material_components_ios/src/components/ProgressView/src
/MaterialProgressView.h" | 18 #import "ios/third_party/material_components_ios/src/components/ProgressView/src
/MaterialProgressView.h" |
| 19 #import "ios/web/public/test/http_server.h" | 19 #import "ios/web/public/test/http_server.h" |
| 20 #import "ios/web/public/test/http_server_util.h" | 20 #import "ios/web/public/test/http_server_util.h" |
| 21 #include "ios/web/public/test/response_providers/html_response_provider.h" | 21 #include "ios/web/public/test/response_providers/html_response_provider.h" |
| 22 #include "url/gurl.h" | 22 #include "url/gurl.h" |
| 23 | 23 |
| 24 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 25 #error "This file requires ARC support." |
| 26 #endif |
| 27 |
| 24 using chrome_test_util::WebViewContainingText; | 28 using chrome_test_util::WebViewContainingText; |
| 25 | 29 |
| 26 namespace { | 30 namespace { |
| 27 | 31 |
| 28 // Text to display in form page. | 32 // Text to display in form page. |
| 29 const char kFormPageText[] = "Form testing page"; | 33 const char kFormPageText[] = "Form testing page"; |
| 30 | 34 |
| 31 // Text to display in infinite loading page. | 35 // Text to display in infinite loading page. |
| 32 const char kPageText[] = "Navigation testing page"; | 36 const char kPageText[] = "Navigation testing page"; |
| 33 | 37 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 54 MDCProgressView* progressView = base::mac::ObjCCast<MDCProgressView>(view); | 58 MDCProgressView* progressView = base::mac::ObjCCast<MDCProgressView>(view); |
| 55 return progressView && progressView.progress == progress; | 59 return progressView && progressView.progress == progress; |
| 56 }; | 60 }; |
| 57 | 61 |
| 58 DescribeToBlock describe = ^(id<GREYDescription> description) { | 62 DescribeToBlock describe = ^(id<GREYDescription> description) { |
| 59 [description | 63 [description |
| 60 appendText:[NSString stringWithFormat:@"progress view with progress:%f", | 64 appendText:[NSString stringWithFormat:@"progress view with progress:%f", |
| 61 progress]]; | 65 progress]]; |
| 62 }; | 66 }; |
| 63 | 67 |
| 64 return [[[GREYElementMatcherBlock alloc] initWithMatchesBlock:matches | 68 return [[GREYElementMatcherBlock alloc] initWithMatchesBlock:matches |
| 65 descriptionBlock:describe] | 69 descriptionBlock:describe]; |
| 66 autorelease]; | |
| 67 } | 70 } |
| 68 | 71 |
| 69 // Response provider that serves the page which never finishes loading. | 72 // Response provider that serves the page which never finishes loading. |
| 70 // TODO(crbug.com/638674): Evaluate if this can move to shared code. | 73 // TODO(crbug.com/638674): Evaluate if this can move to shared code. |
| 71 class InfinitePendingResponseProvider : public HtmlResponseProvider { | 74 class InfinitePendingResponseProvider : public HtmlResponseProvider { |
| 72 public: | 75 public: |
| 73 explicit InfinitePendingResponseProvider(const GURL& url) : url_(url) {} | 76 explicit InfinitePendingResponseProvider(const GURL& url) : url_(url) {} |
| 74 ~InfinitePendingResponseProvider() override {} | 77 ~InfinitePendingResponseProvider() override {} |
| 75 | 78 |
| 76 // HtmlResponseProvider overrides: | 79 // HtmlResponseProvider overrides: |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 assertWithMatcher:grey_notNil()]; | 252 assertWithMatcher:grey_notNil()]; |
| 250 | 253 |
| 251 chrome_test_util::SubmitWebViewFormWithId(kFormID); | 254 chrome_test_util::SubmitWebViewFormWithId(kFormID); |
| 252 | 255 |
| 253 // Verify progress view is not visible. | 256 // Verify progress view is not visible. |
| 254 [[EarlGrey selectElementWithMatcher:grey_kindOfClass([MDCProgressView class])] | 257 [[EarlGrey selectElementWithMatcher:grey_kindOfClass([MDCProgressView class])] |
| 255 assertWithMatcher:grey_notVisible()]; | 258 assertWithMatcher:grey_notVisible()]; |
| 256 } | 259 } |
| 257 | 260 |
| 258 @end | 261 @end |
| OLD | NEW |