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

Side by Side Diff: ios/chrome/browser/metrics/tab_usage_recorder_egtest.mm

Issue 2674293003: [ObjC ARC] Converts ios/chrome/browser/metrics:eg_tests to ARC. (Closed)
Patch Set: typo Created 3 years, 10 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
« no previous file with comments | « ios/chrome/browser/metrics/BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <XCTest/XCTest.h> 6 #import <XCTest/XCTest.h>
7 7
8 #include "base/mac/bind_objc_block.h" 8 #include "base/mac/bind_objc_block.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 22 matching lines...) Expand all
33 #import "ios/chrome/test/earl_grey/chrome_test_case.h" 33 #import "ios/chrome/test/earl_grey/chrome_test_case.h"
34 #import "ios/testing/wait_util.h" 34 #import "ios/testing/wait_util.h"
35 #import "ios/web/public/test/earl_grey/web_view_matchers.h" 35 #import "ios/web/public/test/earl_grey/web_view_matchers.h"
36 #import "ios/web/public/test/http_server.h" 36 #import "ios/web/public/test/http_server.h"
37 #import "ios/web/public/test/http_server_util.h" 37 #import "ios/web/public/test/http_server_util.h"
38 #include "ios/web/public/test/response_providers/delayed_response_provider.h" 38 #include "ios/web/public/test/response_providers/delayed_response_provider.h"
39 #include "ios/web/public/test/response_providers/html_response_provider.h" 39 #include "ios/web/public/test/response_providers/html_response_provider.h"
40 #include "ui/base/l10n/l10n_util.h" 40 #include "ui/base/l10n/l10n_util.h"
41 #include "ui/base/l10n/l10n_util_mac.h" 41 #include "ui/base/l10n/l10n_util_mac.h"
42 42
43 #if !defined(__has_feature) || !__has_feature(objc_arc)
44 #error "This file requires ARC support."
45 #endif
46
43 namespace { 47 namespace {
44 48
45 const char kTestUrl1[] = 49 const char kTestUrl1[] =
46 "http://ios/testing/data/http_server_files/memory_usage.html"; 50 "http://ios/testing/data/http_server_files/memory_usage.html";
47 const char kURL1FirstWord[] = "Page"; 51 const char kURL1FirstWord[] = "Page";
48 const char kTestUrl2[] = 52 const char kTestUrl2[] =
49 "http://ios/testing/data/http_server_files/fullscreen.html"; 53 "http://ios/testing/data/http_server_files/fullscreen.html";
50 const char kURL2FirstWord[] = "Rugby"; 54 const char kURL2FirstWord[] = "Rugby";
51 const char kClearPageScript[] = "document.body.innerHTML='';"; 55 const char kClearPageScript[] = "document.body.innerHTML='';";
52 56
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 // Switch between the tabs. They are currently in memory. 329 // Switch between the tabs. They are currently in memory.
326 chrome_test_util::SelectTabAtIndexInCurrentMode(0); 330 chrome_test_util::SelectTabAtIndexInCurrentMode(0);
327 331
328 // Verify that no page-load count has been recorded. 332 // Verify that no page-load count has been recorded.
329 histogramTester.ExpectTotalCount(kPageLoadsBeforeEvictedTabSelected, 0, 333 histogramTester.ExpectTotalCount(kPageLoadsBeforeEvictedTabSelected, 0,
330 failureBlock); 334 failureBlock);
331 335
332 // Reload each tab. 336 // Reload each tab.
333 for (NSUInteger i = 0; i < numberOfTabs; i++) { 337 for (NSUInteger i = 0; i < numberOfTabs; i++) {
334 chrome_test_util::SelectTabAtIndexInCurrentMode(i); 338 chrome_test_util::SelectTabAtIndexInCurrentMode(i);
335 // Clear the page so that we can check when pade reload is complete. 339 // Clear the page so that we can check when page reload is complete.
336 __block bool finished = false; 340 __block bool finished = false;
337 chrome_test_util::GetCurrentWebState()->ExecuteJavaScript( 341 chrome_test_util::GetCurrentWebState()->ExecuteJavaScript(
338 base::UTF8ToUTF16(kClearPageScript), 342 base::UTF8ToUTF16(kClearPageScript),
339 base::BindBlock(^(const base::Value*) { 343 base::BindBlockArc(^(const base::Value*) {
340 finished = true; 344 finished = true;
341 })); 345 }));
342 346
343 GREYAssert(testing::WaitUntilConditionOrTimeout(1.0, 347 GREYAssert(testing::WaitUntilConditionOrTimeout(1.0,
344 ^{ 348 ^{
345 return finished; 349 return finished;
346 }), 350 }),
347 @"JavaScript to reload each tab did not finish"); 351 @"JavaScript to reload each tab did not finish");
348 [ChromeEarlGreyUI reload]; 352 [ChromeEarlGreyUI reload];
349 [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText( 353 [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText(
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; 952 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
949 } 953 }
950 // The deleted tabs are purged during foregrounding and backgrounding. 954 // The deleted tabs are purged during foregrounding and backgrounding.
951 chrome_test_util::SimulateTabsBackgrounding(); 955 chrome_test_util::SimulateTabsBackgrounding();
952 // Make sure |evicted_tabs_| purged the deleted tabs. 956 // Make sure |evicted_tabs_| purged the deleted tabs.
953 int evicted = chrome_test_util::GetEvictedMainTabCount(); 957 int evicted = chrome_test_util::GetEvictedMainTabCount();
954 GREYAssertEqual(evicted, 0, @"Check number of evicted tabs"); 958 GREYAssertEqual(evicted, 0, @"Check number of evicted tabs");
955 } 959 }
956 960
957 @end 961 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/metrics/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698