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

Side by Side Diff: ios/chrome/browser/ui/ntp/new_tab_page_perftest.mm

Issue 2589803002: Upstream Chrome on iOS source code [6/11]. (Closed)
Patch Set: Created 4 years 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
(Empty)
1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #import "base/test/ios/wait_util.h"
6 #include "ios/chrome/browser/sessions/ios_chrome_tab_restore_service_factory.h"
7 #import "ios/chrome/browser/tabs/tab_model.h"
8 #include "ios/chrome/browser/test/perf_test_with_bvc_ios.h"
9 #import "ios/chrome/browser/ui/browser_view_controller.h"
10 #import "ios/chrome/browser/ui/browser_view_controller_dependency_factory.h"
11
12 namespace {
13
14 const NSTimeInterval kMaxUICatchupDelay = 2.0; // seconds
15
16 class NewTabPagePerfTest : public PerfTestWithBVC {
17 public:
18 NewTabPagePerfTest()
19 : PerfTestWithBVC("NTP - Create",
20 "First Tab",
21 "",
22 false,
23 false,
24 true,
25 10) {}
26
27 protected:
28 void SetUp() override {
29 PerfTestWithBVC::SetUp();
30 IOSChromeTabRestoreServiceFactory::GetInstance()->SetTestingFactory(
31 chrome_browser_state_.get(),
32 IOSChromeTabRestoreServiceFactory::GetDefaultFactory());
33 }
34 base::TimeDelta TimedNewTab() {
35 base::Time startTime = base::Time::NowFromSystemTime();
36 [bvc_ newTab:nil];
37 return base::Time::NowFromSystemTime() - startTime;
38 }
39 void SettleUI() {
40 base::test::ios::WaitUntilCondition(
41 nil, nullptr, base::TimeDelta::FromSecondsD(kMaxUICatchupDelay));
42 }
43 };
44
45 // Output format first test:
46 // [*]RESULT NTP - Create: NTP Gentle Create First Tab= number ms
47 // Output format subsequent average:
48 // [*]RESULT NTP - Create: NTP Gentle Create= number ms
49 TEST_F(NewTabPagePerfTest, OpenNTP_Gentle) {
50 RepeatTimedRuns("NTP Gentle Create",
51 ^(int index) {
52 return TimedNewTab();
53 },
54 ^{
55 SettleUI();
56 });
57 }
58
59 // Output format first test:
60 // [*]RESULT NTP - Create: NTP Hammer Create First Tab= number ms
61 // Output format subsequent average:
62 // [*]RESULT NTP - Create: NTP Hammer Create= number ms
63 TEST_F(NewTabPagePerfTest, OpenNTP_Hammer) {
64 RepeatTimedRuns("NTP Hammer Create",
65 ^(int index) {
66 return TimedNewTab();
67 },
68 nil);
69 // Allows the run loops to run before teardown.
70 SettleUI();
71 }
72
73 } // anonymous namespace
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/ntp/new_tab_page_panel_protocol.mm ('k') | ios/chrome/browser/ui/ntp/new_tab_page_toolbar_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698