| 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 #import <XCTest/XCTest.h> | 6 #import <XCTest/XCTest.h> |
| 7 | 7 |
| 8 #include "base/mac/bind_objc_block.h" | 8 #include "base/mac/bind_objc_block.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 #import "ios/web/public/test/http_server_util.h" | 37 #import "ios/web/public/test/http_server_util.h" |
| 38 #include "ios/web/public/test/response_providers/delayed_response_provider.h" | 38 #include "ios/web/public/test/response_providers/delayed_response_provider.h" |
| 39 #include "ios/web/public/test/response_providers/html_response_provider.h" | 39 #include "ios/web/public/test/response_providers/html_response_provider.h" |
| 40 #include "ui/base/l10n/l10n_util.h" | 40 #include "ui/base/l10n/l10n_util.h" |
| 41 #include "ui/base/l10n/l10n_util_mac.h" | 41 #include "ui/base/l10n/l10n_util_mac.h" |
| 42 | 42 |
| 43 #if !defined(__has_feature) || !__has_feature(objc_arc) | 43 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 44 #error "This file requires ARC support." | 44 #error "This file requires ARC support." |
| 45 #endif | 45 #endif |
| 46 | 46 |
| 47 using chrome_test_util::OpenLinkInNewTabButton; |
| 48 |
| 47 namespace { | 49 namespace { |
| 48 | 50 |
| 49 const char kTestUrl1[] = | 51 const char kTestUrl1[] = |
| 50 "http://ios/testing/data/http_server_files/memory_usage.html"; | 52 "http://ios/testing/data/http_server_files/memory_usage.html"; |
| 51 const char kURL1FirstWord[] = "Page"; | 53 const char kURL1FirstWord[] = "Page"; |
| 52 const char kTestUrl2[] = | 54 const char kTestUrl2[] = |
| 53 "http://ios/testing/data/http_server_files/fullscreen.html"; | 55 "http://ios/testing/data/http_server_files/fullscreen.html"; |
| 54 const char kURL2FirstWord[] = "Rugby"; | 56 const char kURL2FirstWord[] = "Rugby"; |
| 55 const char kClearPageScript[] = "document.body.innerHTML='';"; | 57 const char kClearPageScript[] = "document.body.innerHTML='';"; |
| 56 | 58 |
| (...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 ResetTabUsageRecorder(); | 848 ResetTabUsageRecorder(); |
| 847 | 849 |
| 848 // Open a tab with a link to click. | 850 // Open a tab with a link to click. |
| 849 NewMainTabWithURL(initialURL, "link"); | 851 NewMainTabWithURL(initialURL, "link"); |
| 850 | 852 |
| 851 int numberOfTabs = chrome_test_util::GetMainTabCount(); | 853 int numberOfTabs = chrome_test_util::GetMainTabCount(); |
| 852 [[EarlGrey | 854 [[EarlGrey |
| 853 selectElementWithMatcher:chrome_test_util::WebViewContainingText("link")] | 855 selectElementWithMatcher:chrome_test_util::WebViewContainingText("link")] |
| 854 performAction:grey_longPress()]; | 856 performAction:grey_longPress()]; |
| 855 | 857 |
| 856 [[EarlGrey | 858 [[EarlGrey selectElementWithMatcher:OpenLinkInNewTabButton()] |
| 857 selectElementWithMatcher:chrome_test_util::OpenLinkInNewTabMenuItem()] | |
| 858 performAction:grey_tap()]; | 859 performAction:grey_tap()]; |
| 859 chrome_test_util::AssertMainTabCount(numberOfTabs + 1); | 860 chrome_test_util::AssertMainTabCount(numberOfTabs + 1); |
| 860 | 861 |
| 861 SelectTabUsingUI(base::SysUTF8ToNSString(destinationURL.GetContent())); | 862 SelectTabUsingUI(base::SysUTF8ToNSString(destinationURL.GetContent())); |
| 862 | 863 |
| 863 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; | 864 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; |
| 864 [[EarlGrey | 865 [[EarlGrey |
| 865 selectElementWithMatcher:chrome_test_util::WebViewContainingText("Whee")] | 866 selectElementWithMatcher:chrome_test_util::WebViewContainingText("Whee")] |
| 866 assertWithMatcher:grey_notNil()]; | 867 assertWithMatcher:grey_notNil()]; |
| 867 | 868 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 937 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; | 938 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; |
| 938 } | 939 } |
| 939 // The deleted tabs are purged during foregrounding and backgrounding. | 940 // The deleted tabs are purged during foregrounding and backgrounding. |
| 940 chrome_test_util::SimulateTabsBackgrounding(); | 941 chrome_test_util::SimulateTabsBackgrounding(); |
| 941 // Make sure |evicted_tabs_| purged the deleted tabs. | 942 // Make sure |evicted_tabs_| purged the deleted tabs. |
| 942 int evicted = chrome_test_util::GetEvictedMainTabCount(); | 943 int evicted = chrome_test_util::GetEvictedMainTabCount(); |
| 943 GREYAssertEqual(evicted, 0, @"Check number of evicted tabs"); | 944 GREYAssertEqual(evicted, 0, @"Check number of evicted tabs"); |
| 944 } | 945 } |
| 945 | 946 |
| 946 @end | 947 @end |
| OLD | NEW |