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

Side by Side Diff: ios/web/ui_web_view_util_unittest.mm

Issue 1043243003: Upstream most of ios/web/net (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove accidentally-added clients Created 5 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
« no previous file with comments | « ios/web/ui_web_view_util.mm ('k') | ios/web/web_state/ui/crw_static_file_web_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 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 "ios/web/ui_web_view_util.h"
6
7 #import "ios/web/public/test/test_web_client.h"
8 #include "testing/gtest_mac.h"
9 #include "testing/platform_test.h"
10
11 namespace {
12
13 // Returns user agent string registered for UIWebView.
14 NSString* GetUserAgent() {
15 return [[NSUserDefaults standardUserDefaults] stringForKey:@"UserAgent"];
16 }
17
18 class UIWebViewUtilTest : public PlatformTest {
19 protected:
20 void SetUp() override {
21 PlatformTest::SetUp();
22 test_web_client_.SetUserAgent("DesktopUA", true);
23 test_web_client_.SetUserAgent("RegularUA", false);
24 web::SetWebClient(&test_web_client_);
25 }
26 void TearDown() override {
27 web::SetWebClient(nullptr);
28 PlatformTest::TearDown();
29 }
30 private:
31 // WebClient that returns test user agent.
32 web::TestWebClient test_web_client_;
33 };
34
35 // Tests registration of a non-desktop user agent.
36 TEST_F(UIWebViewUtilTest, BuildAndRegisterNonDesktopUserAgentForUIWebView) {
37 web::BuildAndRegisterUserAgentForUIWebView(@"1231546541321", NO);
38 EXPECT_NSEQ(@"RegularUA (1231546541321)", GetUserAgent());
39 }
40
41 // Tests registration of a desktop user agent.
42 TEST_F(UIWebViewUtilTest, BuildAndRegisterDesktopUserAgentForUIWebView) {
43 web::BuildAndRegisterUserAgentForUIWebView(@"1231546541321", YES);
44 EXPECT_NSEQ(@"DesktopUA (1231546541321)", GetUserAgent());
45 }
46
47 // Tests web::RegisterUserAgentForUIWebView function that it correctly registers
48 // arbitrary user agent.
49 TEST_F(UIWebViewUtilTest, RegisterUserAgentForUIWebView) {
50 web::RegisterUserAgentForUIWebView(@"UA");
51 EXPECT_NSEQ(@"UA", GetUserAgent());
52 }
53
54 } // namespace
OLDNEW
« no previous file with comments | « ios/web/ui_web_view_util.mm ('k') | ios/web/web_state/ui/crw_static_file_web_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698