| 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 #import <map> | 8 #import <map> |
| 9 #import <string> | 9 #import <string> |
| 10 | 10 |
| 11 #include "components/strings/grit/components_strings.h" | 11 #include "components/strings/grit/components_strings.h" |
| 12 #import "ios/chrome/browser/ui/tools_menu/tools_menu_view_controller.h" | 12 #import "ios/chrome/browser/ui/tools_menu/tools_menu_view_controller.h" |
| 13 #include "ios/chrome/browser/ui/ui_util.h" | 13 #include "ios/chrome/browser/ui/ui_util.h" |
| 14 #include "ios/chrome/grit/ios_strings.h" | 14 #include "ios/chrome/grit/ios_strings.h" |
| 15 #import "ios/chrome/test/app/tab_test_util.h" | 15 #import "ios/chrome/test/app/tab_test_util.h" |
| 16 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" | 16 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" |
| 17 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" | 17 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" |
| 18 #import "ios/chrome/test/earl_grey/chrome_matchers.h" | 18 #import "ios/chrome/test/earl_grey/chrome_matchers.h" |
| 19 #import "ios/chrome/test/earl_grey/chrome_test_case.h" | 19 #import "ios/chrome/test/earl_grey/chrome_test_case.h" |
| 20 #import "ios/web/public/test/http_server.h" | 20 #import "ios/web/public/test/http_server.h" |
| 21 #include "ios/web/public/test/http_server_util.h" | 21 #include "ios/web/public/test/http_server_util.h" |
| 22 | 22 |
| 23 #if !defined(__has_feature) || !__has_feature(objc_arc) | 23 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 24 #error "This file requires ARC support." | 24 #error "This file requires ARC support." |
| 25 #endif | 25 #endif |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| 28 const char kURLOfTestPage[] = "http://testPage"; | 28 const char kURLOfTestPage[] = "http://testPage"; |
| 29 std::string const kHTMLOfTestPage = | 29 const char kHTMLOfTestPage[] = |
| 30 "<head><title>TestPageTitle</title></head><body>hello</body>"; | 30 "<head><title>TestPageTitle</title></head><body>hello</body>"; |
| 31 NSString* const kTitleOfTestPage = @"TestPageTitle"; | 31 NSString* const kTitleOfTestPage = @"TestPageTitle"; |
| 32 | 32 |
| 33 // Makes sure at least one tab is opened and opens the recent tab panel. | 33 // Makes sure at least one tab is opened and opens the recent tab panel. |
| 34 void OpenRecentTabsPanel() { | 34 void OpenRecentTabsPanel() { |
| 35 // At least one tab is needed to be able to open the recent tabs panel. | 35 // At least one tab is needed to be able to open the recent tabs panel. |
| 36 if (chrome_test_util::GetMainTabCount() == 0) | 36 if (chrome_test_util::GetMainTabCount() == 0) |
| 37 chrome_test_util::OpenNewTab(); | 37 chrome_test_util::OpenNewTab(); |
| 38 | 38 |
| 39 [ChromeEarlGreyUI openToolsMenu]; | 39 [ChromeEarlGreyUI openToolsMenu]; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 69 | 69 |
| 70 // Earl grey integration tests for Recent Tabs Panel Controller. | 70 // Earl grey integration tests for Recent Tabs Panel Controller. |
| 71 @interface RecentTabsPanelControllerTestCase : ChromeTestCase | 71 @interface RecentTabsPanelControllerTestCase : ChromeTestCase |
| 72 @end | 72 @end |
| 73 | 73 |
| 74 @implementation RecentTabsPanelControllerTestCase | 74 @implementation RecentTabsPanelControllerTestCase |
| 75 | 75 |
| 76 - (void)setUp { | 76 - (void)setUp { |
| 77 [ChromeEarlGrey clearBrowsingHistory]; | 77 [ChromeEarlGrey clearBrowsingHistory]; |
| 78 [super setUp]; | 78 [super setUp]; |
| 79 std::map<GURL, std::string> responses; | 79 web::test::SetUpSimpleHttpServer(std::map<GURL, std::string>{{ |
| 80 const GURL testPageURL = web::test::HttpServer::MakeUrl(kURLOfTestPage); | 80 web::test::HttpServer::MakeUrl(kURLOfTestPage), |
| 81 responses[testPageURL] = kHTMLOfTestPage; | 81 std::string(kHTMLOfTestPage), |
| 82 web::test::SetUpSimpleHttpServer(responses); | 82 }}); |
| 83 } | 83 } |
| 84 | 84 |
| 85 - (void)tearDown { | 85 - (void)tearDown { |
| 86 if (IsIPadIdiom()) { | 86 if (IsIPadIdiom()) { |
| 87 chrome_test_util::OpenNewTab(); | 87 chrome_test_util::OpenNewTab(); |
| 88 NSError* error = nil; | 88 NSError* error = nil; |
| 89 [[EarlGrey selectElementWithMatcher:RecentlyClosedLabelMatcher()] | 89 [[EarlGrey selectElementWithMatcher:RecentlyClosedLabelMatcher()] |
| 90 assertWithMatcher:grey_notNil() | 90 assertWithMatcher:grey_notNil() |
| 91 error:&error]; | 91 error:&error]; |
| 92 // If the Recent Tabs panel is shown, then switch back to the Most Visited | 92 // If the Recent Tabs panel is shown, then switch back to the Most Visited |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 // Tap on the entry for the test page in the Recent Tabs panel and check that | 144 // Tap on the entry for the test page in the Recent Tabs panel and check that |
| 145 // a tab containing the test page was opened. | 145 // a tab containing the test page was opened. |
| 146 [[EarlGrey selectElementWithMatcher:TitleOfTestPage()] | 146 [[EarlGrey selectElementWithMatcher:TitleOfTestPage()] |
| 147 performAction:grey_tap()]; | 147 performAction:grey_tap()]; |
| 148 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()] | 148 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()] |
| 149 assertWithMatcher:chrome_test_util::OmniboxText( | 149 assertWithMatcher:chrome_test_util::OmniboxText( |
| 150 testPageURL.GetContent())]; | 150 testPageURL.GetContent())]; |
| 151 } | 151 } |
| 152 | 152 |
| 153 @end | 153 @end |
| OLD | NEW |