Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Side by Side Diff: ios/chrome/browser/ui/settings/autofill_profile_edit_collection_view_controller_unittest.mm

Issue 2806323003: [ObjC ARC] Converts ios/chrome/browser/ui/settings:unit_tests to ARC. (Closed)
Patch Set: rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "ios/chrome/browser/ui/settings/autofill_profile_edit_collection_view_co ntroller.h" 5 #import "ios/chrome/browser/ui/settings/autofill_profile_edit_collection_view_co ntroller.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/guid.h" 9 #include "base/guid.h"
10 #import "base/mac/scoped_nsobject.h"
11 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
12 #include "base/strings/sys_string_conversions.h" 11 #include "base/strings/sys_string_conversions.h"
13 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
14 #include "components/autofill/core/browser/autofill_profile.h" 13 #include "components/autofill/core/browser/autofill_profile.h"
15 #include "components/autofill/core/browser/personal_data_manager.h" 14 #include "components/autofill/core/browser/personal_data_manager.h"
16 #include "ios/chrome/browser/application_context.h" 15 #include "ios/chrome/browser/application_context.h"
17 #include "ios/chrome/browser/autofill/personal_data_manager_factory.h" 16 #include "ios/chrome/browser/autofill/personal_data_manager_factory.h"
18 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" 17 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h"
19 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" 18 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h"
20 #include "ios/chrome/browser/ui/settings/personal_data_manager_data_changed_obse rver.h" 19 #include "ios/chrome/browser/ui/settings/personal_data_manager_data_changed_obse rver.h"
21 #include "ios/web/public/test/test_web_thread_bundle.h" 20 #include "ios/web/public/test/test_web_thread_bundle.h"
22 #include "testing/platform_test.h" 21 #include "testing/platform_test.h"
23 22
23 #if !defined(__has_feature) || !__has_feature(objc_arc)
24 #error "This file requires ARC support."
25 #endif
26
24 namespace { 27 namespace {
25 28
26 const char kTestFullName[] = "That Guy John"; 29 const char kTestFullName[] = "That Guy John";
27 const char kTestAddressLine1[] = "Some person's garage"; 30 const char kTestAddressLine1[] = "Some person's garage";
28 31
29 static NSArray* FindTextFieldDescendants(UIView* root) { 32 static NSArray* FindTextFieldDescendants(UIView* root) {
30 NSMutableArray* textFields = [NSMutableArray array]; 33 NSMutableArray* textFields = [NSMutableArray array];
31 NSMutableArray* descendants = [NSMutableArray array]; 34 NSMutableArray* descendants = [NSMutableArray array];
32 35
33 [descendants addObject:root]; 36 [descendants addObject:root];
(...skipping 30 matching lines...) Expand all
64 autofill_profile = 67 autofill_profile =
65 autofill::AutofillProfile(guid, "https://www.example.com/"); 68 autofill::AutofillProfile(guid, "https://www.example.com/");
66 autofill_profile.SetRawInfo(autofill::NAME_FULL, 69 autofill_profile.SetRawInfo(autofill::NAME_FULL,
67 base::UTF8ToUTF16(kTestFullName)); 70 base::UTF8ToUTF16(kTestFullName));
68 autofill_profile.SetRawInfo(autofill::ADDRESS_HOME_LINE1, 71 autofill_profile.SetRawInfo(autofill::ADDRESS_HOME_LINE1,
69 base::UTF8ToUTF16(kTestAddressLine1)); 72 base::UTF8ToUTF16(kTestAddressLine1));
70 73
71 personal_data_manager_->SaveImportedProfile(autofill_profile); 74 personal_data_manager_->SaveImportedProfile(autofill_profile);
72 observer.Wait(); // Wait for the completion of the asynchronous operation. 75 observer.Wait(); // Wait for the completion of the asynchronous operation.
73 76
74 autofill_profile_edit_controller_.reset( 77 autofill_profile_edit_controller_ =
75 [[AutofillProfileEditCollectionViewController 78 [AutofillProfileEditCollectionViewController
76 controllerWithProfile:autofill_profile 79 controllerWithProfile:autofill_profile
77 personalDataManager:personal_data_manager_] retain]); 80 personalDataManager:personal_data_manager_];
78 } 81 }
79 82
80 web::TestWebThreadBundle thread_bundle_; 83 web::TestWebThreadBundle thread_bundle_;
81 std::unique_ptr<TestChromeBrowserState> chrome_browser_state_; 84 std::unique_ptr<TestChromeBrowserState> chrome_browser_state_;
82 autofill::PersonalDataManager* personal_data_manager_; 85 autofill::PersonalDataManager* personal_data_manager_;
83 base::scoped_nsobject<AutofillProfileEditCollectionViewController> 86 AutofillProfileEditCollectionViewController*
84 autofill_profile_edit_controller_; 87 autofill_profile_edit_controller_;
85 }; 88 };
86 89
87 // Default test case of no addresses or credit cards. 90 // Default test case of no addresses or credit cards.
88 // TODO(crbug.com/375196): This test is flaky. 91 // TODO(crbug.com/375196): This test is flaky.
89 TEST_F(AutofillProfileEditCollectionViewControllerTest, 92 TEST_F(AutofillProfileEditCollectionViewControllerTest,
90 FLAKY_TestInitialization) { 93 FLAKY_TestInitialization) {
91 CollectionViewModel* model = 94 CollectionViewModel* model =
92 [autofill_profile_edit_controller_ collectionViewModel]; 95 [autofill_profile_edit_controller_ collectionViewModel];
93 96
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 EXPECT_TRUE([cell isKindOfClass:[MDCCollectionViewCell class]]); 129 EXPECT_TRUE([cell isKindOfClass:[MDCCollectionViewCell class]]);
127 textFields = FindTextFieldDescendants(cell); 130 textFields = FindTextFieldDescendants(cell);
128 EXPECT_TRUE([textFields count] > 0); 131 EXPECT_TRUE([textFields count] > 0);
129 field = [textFields objectAtIndex:0]; 132 field = [textFields objectAtIndex:0];
130 EXPECT_TRUE([field isKindOfClass:[UITextField class]]); 133 EXPECT_TRUE([field isKindOfClass:[UITextField class]]);
131 EXPECT_TRUE([[field text] 134 EXPECT_TRUE([[field text]
132 isEqualToString:base::SysUTF8ToNSString(kTestAddressLine1)]); 135 isEqualToString:base::SysUTF8ToNSString(kTestAddressLine1)]);
133 } 136 }
134 137
135 } // namespace 138 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698