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) | |
24 #error "This file requires ARC support." | |
25 #endif | |
26 | |
23 namespace { | 27 namespace { |
24 const char kURLOfTestPage[] = "http://testPage"; | 28 const char kURLOfTestPage[] = "http://testPage"; |
25 std::string const kHTMLOfTestPage = | 29 std::string const kHTMLOfTestPage = |
sdefresne
2017/02/06 15:24:58
Could you remove this static non-POD object while
| |
26 "<head><title>TestPageTitle</title></head><body>hello</body>"; | 30 "<head><title>TestPageTitle</title></head><body>hello</body>"; |
27 NSString* const kTitleOfTestPage = @"TestPageTitle"; | 31 NSString* const kTitleOfTestPage = @"TestPageTitle"; |
28 | 32 |
29 // 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. |
30 void OpenRecentTabsPanel() { | 34 void OpenRecentTabsPanel() { |
31 // 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. |
32 if (chrome_test_util::GetMainTabCount() == 0) | 36 if (chrome_test_util::GetMainTabCount() == 0) |
33 chrome_test_util::OpenNewTab(); | 37 chrome_test_util::OpenNewTab(); |
34 | 38 |
35 [ChromeEarlGreyUI openToolsMenu]; | 39 [ChromeEarlGreyUI openToolsMenu]; |
(...skipping 29 matching lines...) Expand all Loading... | |
65 | 69 |
66 // Earl grey integration tests for Recent Tabs Panel Controller. | 70 // Earl grey integration tests for Recent Tabs Panel Controller. |
67 @interface RecentTabsPanelControllerTestCase : ChromeTestCase | 71 @interface RecentTabsPanelControllerTestCase : ChromeTestCase |
68 @end | 72 @end |
69 | 73 |
70 @implementation RecentTabsPanelControllerTestCase | 74 @implementation RecentTabsPanelControllerTestCase |
71 | 75 |
72 - (void)setUp { | 76 - (void)setUp { |
73 [ChromeEarlGrey clearBrowsingHistory]; | 77 [ChromeEarlGrey clearBrowsingHistory]; |
74 [super setUp]; | 78 [super setUp]; |
75 std::map<GURL, std::string> responses; | 79 std::map<GURL, std::string> responses; |
sdefresne
2017/02/06 15:24:58
nit, optional: you can also use initialiser-list f
| |
76 const GURL testPageURL = web::test::HttpServer::MakeUrl(kURLOfTestPage); | 80 const GURL testPageURL = web::test::HttpServer::MakeUrl(kURLOfTestPage); |
77 responses[testPageURL] = kHTMLOfTestPage; | 81 responses[testPageURL] = kHTMLOfTestPage; |
sdefresne
2017/02/06 15:24:58
responses[testPageURL] = std::string(kHTMLOfTestPa
| |
78 web::test::SetUpSimpleHttpServer(responses); | 82 web::test::SetUpSimpleHttpServer(responses); |
79 } | 83 } |
80 | 84 |
81 - (void)tearDown { | 85 - (void)tearDown { |
82 if (IsIPadIdiom()) { | 86 if (IsIPadIdiom()) { |
83 chrome_test_util::OpenNewTab(); | 87 chrome_test_util::OpenNewTab(); |
84 NSError* error = nil; | 88 NSError* error = nil; |
85 [[EarlGrey selectElementWithMatcher:RecentlyClosedLabelMatcher()] | 89 [[EarlGrey selectElementWithMatcher:RecentlyClosedLabelMatcher()] |
86 assertWithMatcher:grey_notNil() | 90 assertWithMatcher:grey_notNil() |
87 error:&error]; | 91 error:&error]; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
140 // 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 |
141 // a tab containing the test page was opened. | 145 // a tab containing the test page was opened. |
142 [[EarlGrey selectElementWithMatcher:TitleOfTestPage()] | 146 [[EarlGrey selectElementWithMatcher:TitleOfTestPage()] |
143 performAction:grey_tap()]; | 147 performAction:grey_tap()]; |
144 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()] | 148 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()] |
145 assertWithMatcher:chrome_test_util::OmniboxText( | 149 assertWithMatcher:chrome_test_util::OmniboxText( |
146 testPageURL.GetContent())]; | 150 testPageURL.GetContent())]; |
147 } | 151 } |
148 | 152 |
149 @end | 153 @end |
OLD | NEW |