| 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 #import "base/mac/scoped_nsobject.h" | 7 #import "base/mac/scoped_nsobject.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 "components/content_settings/core/browser/host_content_settings_map.h" | 10 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 11 #include "components/content_settings/core/common/content_settings.h" | 11 #include "components/content_settings/core/common/content_settings.h" |
| 12 #include "ios/chrome/browser/content_settings/host_content_settings_map_factory.
h" | 12 #include "ios/chrome/browser/content_settings/host_content_settings_map_factory.
h" |
| 13 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" | 13 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" |
| 14 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" | 14 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" |
| 15 #import "ios/chrome/test/app/chrome_test_util.h" | 15 #import "ios/chrome/test/app/chrome_test_util.h" |
| 16 #include "ios/chrome/test/app/history_test_util.h" | 16 #include "ios/chrome/test/app/history_test_util.h" |
| 17 #include "ios/chrome/test/app/navigation_test_util.h" | 17 #include "ios/chrome/test/app/navigation_test_util.h" |
| 18 #include "ios/chrome/test/app/web_view_interaction_test_util.h" | 18 #include "ios/chrome/test/app/web_view_interaction_test_util.h" |
| 19 #import "ios/chrome/test/earl_grey/chrome_assertions.h" |
| 19 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" | 20 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" |
| 20 #import "ios/chrome/test/earl_grey/chrome_matchers.h" | 21 #import "ios/chrome/test/earl_grey/chrome_matchers.h" |
| 21 #import "ios/chrome/test/earl_grey/chrome_test_case.h" | 22 #import "ios/chrome/test/earl_grey/chrome_test_case.h" |
| 22 #import "ios/testing/wait_util.h" | 23 #import "ios/testing/wait_util.h" |
| 23 #import "ios/web/public/test/http_server.h" | 24 #import "ios/web/public/test/http_server.h" |
| 24 #include "ios/web/public/test/http_server_util.h" | 25 #include "ios/web/public/test/http_server_util.h" |
| 25 #include "ios/web/public/test/response_providers/html_response_provider.h" | 26 #include "ios/web/public/test/response_providers/html_response_provider.h" |
| 26 #include "url/gurl.h" | 27 #include "url/gurl.h" |
| 27 | 28 |
| 28 using chrome_test_util::WebViewContainingText; | 29 using chrome_test_util::WebViewContainingText; |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 // 2nd hit to server. Verify hitCount. | 237 // 2nd hit to server. Verify hitCount. |
| 237 [ChromeEarlGrey loadURL:cacheTestThirdPageURL]; | 238 [ChromeEarlGrey loadURL:cacheTestThirdPageURL]; |
| 238 [[EarlGrey | 239 [[EarlGrey |
| 239 selectElementWithMatcher:WebViewContainingText("serverHitCounter: 2")] | 240 selectElementWithMatcher:WebViewContainingText("serverHitCounter: 2")] |
| 240 assertWithMatcher:grey_notNil()]; | 241 assertWithMatcher:grey_notNil()]; |
| 241 | 242 |
| 242 // Open the first page in a new tab. Verify that cache was not used. Must | 243 // Open the first page in a new tab. Verify that cache was not used. Must |
| 243 // first allow popups. | 244 // first allow popups. |
| 244 ScopedBlockPopupsPref prefSetter(CONTENT_SETTING_ALLOW); | 245 ScopedBlockPopupsPref prefSetter(CONTENT_SETTING_ALLOW); |
| 245 chrome_test_util::TapWebViewElementWithId(kCacheTestLinkID); | 246 chrome_test_util::TapWebViewElementWithId(kCacheTestLinkID); |
| 247 chrome_test_util::AssertMainTabCount(2); |
| 246 [ChromeEarlGrey waitForPageToFinishLoading]; | 248 [ChromeEarlGrey waitForPageToFinishLoading]; |
| 247 [[EarlGrey selectElementWithMatcher:WebViewContainingText("First Page")] | 249 [[EarlGrey selectElementWithMatcher:WebViewContainingText("First Page")] |
| 248 assertWithMatcher:grey_notNil()]; | 250 assertWithMatcher:grey_notNil()]; |
| 249 [[EarlGrey | 251 [[EarlGrey |
| 250 selectElementWithMatcher:WebViewContainingText("serverHitCounter: 3")] | 252 selectElementWithMatcher:WebViewContainingText("serverHitCounter: 3")] |
| 251 assertWithMatcher:grey_notNil()]; | 253 assertWithMatcher:grey_notNil()]; |
| 252 } | 254 } |
| 253 | 255 |
| 254 // Tests that cache is not used when selecting omnibox suggested website, even | 256 // Tests that cache is not used when selecting omnibox suggested website, even |
| 255 // though cache for that website exists. | 257 // though cache for that website exists. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 279 | 281 |
| 280 // Verify title and hitCount. Cache should not be used. | 282 // Verify title and hitCount. Cache should not be used. |
| 281 [[EarlGrey selectElementWithMatcher:WebViewContainingText("First Page")] | 283 [[EarlGrey selectElementWithMatcher:WebViewContainingText("First Page")] |
| 282 assertWithMatcher:grey_notNil()]; | 284 assertWithMatcher:grey_notNil()]; |
| 283 [[EarlGrey | 285 [[EarlGrey |
| 284 selectElementWithMatcher:WebViewContainingText("serverHitCounter: 2")] | 286 selectElementWithMatcher:WebViewContainingText("serverHitCounter: 2")] |
| 285 assertWithMatcher:grey_notNil()]; | 287 assertWithMatcher:grey_notNil()]; |
| 286 } | 288 } |
| 287 | 289 |
| 288 @end | 290 @end |
| OLD | NEW |