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

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

Issue 2827313002: Replace drainUntilIdle with a dispatch_barrier_sync for Breakpad tests (Closed)
Patch Set: 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 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 #include <map> 8 #include <map>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 } 463 }
464 464
465 - (void)setMetricsReportingEnabled:(BOOL)reportingEnabled 465 - (void)setMetricsReportingEnabled:(BOOL)reportingEnabled
466 wifiOnly:(BOOL)wifiOnly { 466 wifiOnly:(BOOL)wifiOnly {
467 chrome_test_util::SetBooleanLocalStatePref( 467 chrome_test_util::SetBooleanLocalStatePref(
468 metrics::prefs::kMetricsReportingEnabled, reportingEnabled); 468 metrics::prefs::kMetricsReportingEnabled, reportingEnabled);
469 chrome_test_util::SetBooleanLocalStatePref(prefs::kMetricsReportingWifiOnly, 469 chrome_test_util::SetBooleanLocalStatePref(prefs::kMetricsReportingWifiOnly,
470 wifiOnly); 470 wifiOnly);
471 // Breakpad uses dispatch_async to update its state. Wait to get to a 471 // Breakpad uses dispatch_async to update its state. Wait to get to a
472 // consistent state. 472 // consistent state.
473 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; 473 chrome_test_util::WaitForBreakpadQueue();
474 } 474 }
475 475
476 // Checks for a given service that it is both recording and uploading, where 476 // Checks for a given service that it is both recording and uploading, where
477 // appropriate. 477 // appropriate.
478 - (void)assertMetricsServiceEnabled:(MetricsServiceType)serviceType { 478 - (void)assertMetricsServiceEnabled:(MetricsServiceType)serviceType {
479 switch (serviceType) { 479 switch (serviceType) {
480 case kMetrics: 480 case kMetrics:
481 GREYAssertTrue(chrome_test_util::IsMetricsRecordingEnabled(), 481 GREYAssertTrue(chrome_test_util::IsMetricsRecordingEnabled(),
482 @"Metrics recording should be enabled."); 482 @"Metrics recording should be enabled.");
483 GREYAssertTrue(chrome_test_util::IsMetricsReportingEnabled(), 483 GREYAssertTrue(chrome_test_util::IsMetricsReportingEnabled(),
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 // the services, turning on and off according to the rules laid out above. 588 // the services, turning on and off according to the rules laid out above.
589 589
590 // kMetricsReportingEnabled ON and kMetricsReportingWifiOnly ON. 590 // kMetricsReportingEnabled ON and kMetricsReportingWifiOnly ON.
591 [self setMetricsReportingEnabled:YES wifiOnly:YES]; 591 [self setMetricsReportingEnabled:YES wifiOnly:YES];
592 // Service should be enabled. 592 // Service should be enabled.
593 [self assertMetricsServiceEnabled:serviceType]; 593 [self assertMetricsServiceEnabled:serviceType];
594 594
595 // Set the network to use a cellular network, which should disable uploading 595 // Set the network to use a cellular network, which should disable uploading
596 // when the wifi-only flag is set. 596 // when the wifi-only flag is set.
597 chrome_test_util::SetWWANStateTo(YES); 597 chrome_test_util::SetWWANStateTo(YES);
598 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; 598 chrome_test_util::WaitForBreakpadQueue();
599 [self assertMetricsServiceEnabledButNotUploading:serviceType]; 599 [self assertMetricsServiceEnabledButNotUploading:serviceType];
600 600
601 // Turn off cellular network usage, which should enable uploading. 601 // Turn off cellular network usage, which should enable uploading.
602 chrome_test_util::SetWWANStateTo(NO); 602 chrome_test_util::SetWWANStateTo(NO);
603 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; 603 chrome_test_util::WaitForBreakpadQueue();
604 [self assertMetricsServiceEnabled:serviceType]; 604 [self assertMetricsServiceEnabled:serviceType];
605 605
606 // kMetricsReportingEnabled ON and kMetricsReportingWifiOnly OFF 606 // kMetricsReportingEnabled ON and kMetricsReportingWifiOnly OFF
607 [self setMetricsReportingEnabled:YES wifiOnly:NO]; 607 [self setMetricsReportingEnabled:YES wifiOnly:NO];
608 [self assertMetricsServiceEnabled:serviceType]; 608 [self assertMetricsServiceEnabled:serviceType];
609 #else 609 #else
610 // Development build. Do not allow any recording or uploading of data. 610 // Development build. Do not allow any recording or uploading of data.
611 // Specifically, the kMetricsReportingEnabled preference is completely 611 // Specifically, the kMetricsReportingEnabled preference is completely
612 // disregarded for non-official builds, and checking its value always returns 612 // disregarded for non-official builds, and checking its value always returns
613 // false (NO). 613 // false (NO).
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 performAction:grey_tap()]; 1031 performAction:grey_tap()];
1032 [[EarlGrey selectElementWithMatcher:PrivacyButton()] 1032 [[EarlGrey selectElementWithMatcher:PrivacyButton()]
1033 performAction:grey_tap()]; 1033 performAction:grey_tap()];
1034 [[EarlGrey selectElementWithMatcher:SendUsageDataButton()] 1034 [[EarlGrey selectElementWithMatcher:SendUsageDataButton()]
1035 performAction:grey_tap()]; 1035 performAction:grey_tap()];
1036 chrome_test_util::VerifyAccessibilityForCurrentScreen(); 1036 chrome_test_util::VerifyAccessibilityForCurrentScreen();
1037 [self closeSubSettingsMenu]; 1037 [self closeSubSettingsMenu];
1038 } 1038 }
1039 1039
1040 @end 1040 @end
OLDNEW
« no previous file with comments | « no previous file | ios/chrome/test/app/chrome_test_util.h » ('j') | ios/chrome/test/app/chrome_test_util.mm » ('J')

Powered by Google App Engine
This is Rietveld 408576698