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/scoped_nsobject.h" | |
9 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
10 #include "components/metrics/metrics_pref_names.h" | 9 #include "components/metrics/metrics_pref_names.h" |
11 #include "components/metrics/metrics_reporting_default_state.h" | 10 #include "components/metrics/metrics_reporting_default_state.h" |
12 #include "components/prefs/pref_member.h" | 11 #include "components/prefs/pref_member.h" |
13 #include "components/prefs/pref_service.h" | 12 #include "components/prefs/pref_service.h" |
14 #include "components/signin/core/browser/signin_manager.h" | 13 #include "components/signin/core/browser/signin_manager.h" |
15 #import "ios/chrome/app/main_controller.h" | 14 #import "ios/chrome/app/main_controller.h" |
16 #include "ios/chrome/browser/application_context.h" | 15 #include "ios/chrome/browser/application_context.h" |
17 #import "ios/chrome/browser/geolocation/omnibox_geolocation_controller+Testing.h
" | 16 #import "ios/chrome/browser/geolocation/omnibox_geolocation_controller+Testing.h
" |
18 #import "ios/chrome/browser/geolocation/omnibox_geolocation_controller.h" | 17 #import "ios/chrome/browser/geolocation/omnibox_geolocation_controller.h" |
19 #import "ios/chrome/browser/geolocation/test_location_manager.h" | 18 #import "ios/chrome/browser/geolocation/test_location_manager.h" |
20 #include "ios/chrome/browser/signin/signin_manager_factory.h" | 19 #include "ios/chrome/browser/signin/signin_manager_factory.h" |
21 #include "ios/chrome/browser/sync/sync_setup_service.h" | 20 #include "ios/chrome/browser/sync/sync_setup_service.h" |
22 #include "ios/chrome/browser/sync/sync_setup_service_factory.h" | 21 #include "ios/chrome/browser/sync/sync_setup_service_factory.h" |
23 #import "ios/chrome/browser/ui/first_run/first_run_chrome_signin_view_controller
.h" | 22 #import "ios/chrome/browser/ui/first_run/first_run_chrome_signin_view_controller
.h" |
24 #include "ios/chrome/browser/ui/first_run/welcome_to_chrome_view_controller.h" | 23 #include "ios/chrome/browser/ui/first_run/welcome_to_chrome_view_controller.h" |
25 #include "ios/chrome/grit/ios_strings.h" | 24 #include "ios/chrome/grit/ios_strings.h" |
26 #import "ios/chrome/test/app/chrome_test_util.h" | 25 #import "ios/chrome/test/app/chrome_test_util.h" |
27 #import "ios/chrome/test/earl_grey/chrome_matchers.h" | 26 #import "ios/chrome/test/earl_grey/chrome_matchers.h" |
28 #import "ios/chrome/test/earl_grey/chrome_test_case.h" | 27 #import "ios/chrome/test/earl_grey/chrome_test_case.h" |
29 #import "ios/public/provider/chrome/browser/signin/fake_chrome_identity.h" | 28 #import "ios/public/provider/chrome/browser/signin/fake_chrome_identity.h" |
30 #import "ios/public/provider/chrome/browser/signin/fake_chrome_identity_service.
h" | 29 #import "ios/public/provider/chrome/browser/signin/fake_chrome_identity_service.
h" |
31 #include "ui/base/l10n/l10n_util.h" | 30 #include "ui/base/l10n/l10n_util.h" |
32 | 31 |
| 32 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 33 #error "This file requires ARC support." |
| 34 #endif |
| 35 |
33 namespace { | 36 namespace { |
34 | 37 |
35 // Returns a fake identity. | 38 // Returns a fake identity. |
36 ChromeIdentity* GetFakeIdentity() { | 39 ChromeIdentity* GetFakeIdentity() { |
37 return [FakeChromeIdentity identityWithEmail:@"foo@gmail.com" | 40 return [FakeChromeIdentity identityWithEmail:@"foo@gmail.com" |
38 gaiaID:@"fooID" | 41 gaiaID:@"fooID" |
39 name:@"Fake Foo"]; | 42 name:@"Fake Foo"]; |
40 } | 43 } |
41 | 44 |
42 // Taps the button with accessibility labelId |message_id|. | 45 // Taps the button with accessibility labelId |message_id|. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 81 |
79 BooleanPrefMember metricsEnabledPref; | 82 BooleanPrefMember metricsEnabledPref; |
80 metricsEnabledPref.Init(metrics::prefs::kMetricsReportingEnabled, | 83 metricsEnabledPref.Init(metrics::prefs::kMetricsReportingEnabled, |
81 GetApplicationContext()->GetLocalState()); | 84 GetApplicationContext()->GetLocalState()); |
82 metricsEnabledPref.SetValue(NO); | 85 metricsEnabledPref.SetValue(NO); |
83 IntegerPrefMember defaultOptInPref; | 86 IntegerPrefMember defaultOptInPref; |
84 defaultOptInPref.Init(metrics::prefs::kMetricsDefaultOptIn, | 87 defaultOptInPref.Init(metrics::prefs::kMetricsDefaultOptIn, |
85 GetApplicationContext()->GetLocalState()); | 88 GetApplicationContext()->GetLocalState()); |
86 defaultOptInPref.SetValue(metrics::EnableMetricsDefault::DEFAULT_UNKNOWN); | 89 defaultOptInPref.SetValue(metrics::EnableMetricsDefault::DEFAULT_UNKNOWN); |
87 | 90 |
88 base::scoped_nsobject<TestLocationManager> locationManager( | 91 TestLocationManager* locationManager = [[TestLocationManager alloc] init]; |
89 [[TestLocationManager alloc] init]); | |
90 [locationManager setLocationServicesEnabled:NO]; | 92 [locationManager setLocationServicesEnabled:NO]; |
91 [[OmniboxGeolocationController sharedInstance] | 93 [[OmniboxGeolocationController sharedInstance] |
92 setLocationManager:locationManager]; | 94 setLocationManager:locationManager]; |
93 } | 95 } |
94 | 96 |
95 + (void)tearDown { | 97 + (void)tearDown { |
96 IntegerPrefMember defaultOptInPref; | 98 IntegerPrefMember defaultOptInPref; |
97 defaultOptInPref.Init(metrics::prefs::kMetricsDefaultOptIn, | 99 defaultOptInPref.Init(metrics::prefs::kMetricsDefaultOptIn, |
98 GetApplicationContext()->GetLocalState()); | 100 GetApplicationContext()->GetLocalState()); |
99 defaultOptInPref.SetValue(metrics::EnableMetricsDefault::DEFAULT_UNKNOWN); | 101 defaultOptInPref.SetValue(metrics::EnableMetricsDefault::DEFAULT_UNKNOWN); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 @"Sync shouldn't have finished its original setup yet"); | 217 @"Sync shouldn't have finished its original setup yet"); |
216 | 218 |
217 // Close Settings, user is still signed in and sync is now starting. | 219 // Close Settings, user is still signed in and sync is now starting. |
218 TapButtonWithLabelId(IDS_IOS_NAVIGATION_BAR_DONE_BUTTON); | 220 TapButtonWithLabelId(IDS_IOS_NAVIGATION_BAR_DONE_BUTTON); |
219 AssertAuthenticatedIdentityInActiveProfile(identity); | 221 AssertAuthenticatedIdentityInActiveProfile(identity); |
220 GREYAssertTrue(sync_service->HasFinishedInitialSetup(), | 222 GREYAssertTrue(sync_service->HasFinishedInitialSetup(), |
221 @"Sync should have finished its original setup"); | 223 @"Sync should have finished its original setup"); |
222 } | 224 } |
223 | 225 |
224 @end | 226 @end |
OLD | NEW |