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

Unified Diff: ios/chrome/browser/web/early_page_script_perftest.mm

Issue 2580333003: Upstream Chrome on iOS source code [10/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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/chrome/browser/web/chrome_web_test.mm ('k') | ios/chrome/browser/web/error_page_content.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/web/early_page_script_perftest.mm
diff --git a/ios/chrome/browser/web/early_page_script_perftest.mm b/ios/chrome/browser/web/early_page_script_perftest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..bca6bf9bcd2f10942b91d4cd4e7ba270b70898f6
--- /dev/null
+++ b/ios/chrome/browser/web/early_page_script_perftest.mm
@@ -0,0 +1,60 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/mac/bundle_locations.h"
+#include "base/mac/scoped_nsobject.h"
+#include "base/timer/elapsed_timer.h"
+#include "ios/chrome/test/base/perf_test_ios.h"
+#import "ios/web/public/test/js_test_util.h"
+#include "ios/web/public/test/test_browser_state.h"
+#import "ios/web/public/web_view_creation_util.h"
+#import "ios/web/web_state/js/page_script_util.h"
+
+#import <Foundation/Foundation.h>
+#import <WebKit/WebKit.h>
+
+namespace {
+
+// Class for testing early page script injection into WKWebView.
+// TODO(crbug.com/583218): improve this test to use WKUserScript injections.
+class EarlyPageScriptPerfTest : public PerfTest {
+ protected:
+ EarlyPageScriptPerfTest() : PerfTest("Early Page Script for WKWebView") {
+ web_view_.reset([web::BuildWKWebView(CGRectZero, &browser_state_) retain]);
+ }
+
+ // Injects early script into WKWebView.
+ void InjectEarlyScript() {
+ web::ExecuteJavaScript(web_view_, web::GetEarlyPageScript());
+ }
+
+ // BrowserState required for web view creation.
+ web::TestBrowserState browser_state_;
+ // WKWebView to test scripts injections.
+ base::scoped_nsobject<WKWebView> web_view_;
+};
+
+// Tests script loading time.
+TEST_F(EarlyPageScriptPerfTest, ScriptLoading) {
+ RepeatTimedRuns("Loading",
+ ^base::TimeDelta(int) {
+ base::ElapsedTimer timer;
+ web::GetEarlyPageScript();
+ return timer.Elapsed();
+ },
+ nil);
+}
+
+// Tests injection time into a bare web view.
+TEST_F(EarlyPageScriptPerfTest, BareWebViewInjection) {
+ RepeatTimedRuns("Bare web view injection",
+ ^base::TimeDelta(int) {
+ base::ElapsedTimer timer;
+ InjectEarlyScript();
+ return timer.Elapsed();
+ },
+ nil);
+}
+
+} // namespace
« no previous file with comments | « ios/chrome/browser/web/chrome_web_test.mm ('k') | ios/chrome/browser/web/error_page_content.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698