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 <UIKit/UIKit.h> | 6 #import <UIKit/UIKit.h> |
7 #import <XCTest/XCTest.h> | 7 #import <XCTest/XCTest.h> |
8 | 8 |
9 #include "base/mac/scoped_nsobject.h" | 9 #include "base/mac/scoped_nsobject.h" |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
11 #include "components/reading_list/ios/reading_list_model.h" | 11 #include "components/reading_list/ios/reading_list_model.h" |
12 #include "ios/chrome/browser/reading_list/reading_list_model_factory.h" | 12 #include "ios/chrome/browser/reading_list/reading_list_model_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/browser/ui/reading_list/reading_list_collection_view_item.h" | 15 #import "ios/chrome/browser/ui/reading_list/reading_list_collection_view_item.h" |
16 #include "ios/chrome/grit/ios_strings.h" | 16 #include "ios/chrome/grit/ios_strings.h" |
17 #import "ios/chrome/test/app/chrome_test_util.h" | 17 #import "ios/chrome/test/app/chrome_test_util.h" |
| 18 #import "ios/chrome/test/earl_grey/accessibility_util.h" |
18 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" | 19 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" |
19 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" | 20 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.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/third_party/material_components_ios/src/components/Snackbar/src/Mat
erialSnackbar.h" | 24 #import "ios/third_party/material_components_ios/src/components/Snackbar/src/Mat
erialSnackbar.h" |
24 #import "ios/web/public/test/http_server.h" | 25 #import "ios/web/public/test/http_server.h" |
25 #import "ios/web/public/test/http_server_util.h" | 26 #import "ios/web/public/test/http_server_util.h" |
26 | 27 |
27 namespace { | 28 namespace { |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 | 172 |
172 @implementation ReadingListTestCase | 173 @implementation ReadingListTestCase |
173 | 174 |
174 - (void)setUp { | 175 - (void)setUp { |
175 [super setUp]; | 176 [super setUp]; |
176 ReadingListModel* model = GetReadingListModel(); | 177 ReadingListModel* model = GetReadingListModel(); |
177 for (const GURL& url : model->Keys()) | 178 for (const GURL& url : model->Keys()) |
178 model->RemoveEntryByURL(url); | 179 model->RemoveEntryByURL(url); |
179 } | 180 } |
180 | 181 |
| 182 // Tests that the Reading List view is accessible. |
| 183 - (void)testAccessibility { |
| 184 AddEntriesAndEnterEdit(); |
| 185 // In edit mode. |
| 186 chrome_test_util::VerifyAccessibilityForCurrentScreen(); |
| 187 TapButtonWithID(IDS_IOS_READING_LIST_CANCEL_BUTTON); |
| 188 chrome_test_util::VerifyAccessibilityForCurrentScreen(); |
| 189 } |
| 190 |
181 // Tests that sharing a web page to the Reading List results in a snackbar | 191 // Tests that sharing a web page to the Reading List results in a snackbar |
182 // appearing, and that the Reading List entry is present in the Reading List. | 192 // appearing, and that the Reading List entry is present in the Reading List. |
183 - (void)testSavingToReadingList { | 193 - (void)testSavingToReadingList { |
184 // Setup a server serving a page at http://potato with the title "tomato". | 194 // Setup a server serving a page at http://potato with the title "tomato". |
185 std::map<GURL, std::string> responses; | 195 std::map<GURL, std::string> responses; |
186 const GURL regularPageURL = web::test::HttpServer::MakeUrl("http://potato"); | 196 const GURL regularPageURL = web::test::HttpServer::MakeUrl("http://potato"); |
187 responses[regularPageURL] = "<html><head><title>tomato</title></head></html>"; | 197 responses[regularPageURL] = "<html><head><title>tomato</title></head></html>"; |
188 web::test::SetUpSimpleHttpServer(responses); | 198 web::test::SetUpSimpleHttpServer(responses); |
189 | 199 |
190 // Open http://potato | 200 // Open http://potato |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 // Tap the action sheet. | 431 // Tap the action sheet. |
422 TapButtonWithID(IDS_IOS_READING_LIST_MARK_READ_BUTTON); | 432 TapButtonWithID(IDS_IOS_READING_LIST_MARK_READ_BUTTON); |
423 | 433 |
424 AssertAllEntriesVisible(); | 434 AssertAllEntriesVisible(); |
425 XCTAssertEqual(kNumberReadEntries + 1, ModelReadSize(GetReadingListModel())); | 435 XCTAssertEqual(kNumberReadEntries + 1, ModelReadSize(GetReadingListModel())); |
426 XCTAssertEqual(kNumberUnreadEntries - 1, | 436 XCTAssertEqual(kNumberUnreadEntries - 1, |
427 GetReadingListModel()->unread_size()); | 437 GetReadingListModel()->unread_size()); |
428 } | 438 } |
429 | 439 |
430 @end | 440 @end |
OLD | NEW |