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

Side by Side Diff: chrome/common/chrome_content_client_unittest.cc

Issue 2356253006: Make SplitStringUsingSubstr have consistent args. (Closed)
Patch Set: Created 4 years, 3 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/common/chrome_content_client.h" 5 #include "chrome/common/chrome_content_client.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/strings/string_split.h" 9 #include "base/strings/string_split.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "base/test/scoped_command_line.h" 11 #include "base/test/scoped_command_line.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "content/public/common/content_switches.h" 13 #include "content/public/common/content_switches.h"
14 #include "extensions/common/constants.h" 14 #include "extensions/common/constants.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "url/gurl.h" 16 #include "url/gurl.h"
17 #include "url/origin.h" 17 #include "url/origin.h"
18 #include "url/url_util.h" 18 #include "url/url_util.h"
19 19
20 namespace { 20 namespace {
21 21
22 void CheckUserAgentStringOrdering(bool mobile_device) { 22 void CheckUserAgentStringOrdering(bool mobile_device) {
23 std::vector<std::string> pieces; 23 std::vector<std::string> pieces;
24 24
25 // Check if the pieces of the user agent string come in the correct order. 25 // Check if the pieces of the user agent string come in the correct order.
26 ChromeContentClient content_client; 26 ChromeContentClient content_client;
27 std::string buffer = content_client.GetUserAgent(); 27 std::string buffer = content_client.GetUserAgent();
28 28
29 base::SplitStringUsingSubstr(buffer, "Mozilla/5.0 (", &pieces); 29 pieces = base::SplitStringUsingSubstr(buffer, "Mozilla/5.0 (",
30 base::TRIM_WHITESPACE,
31 base::SPLIT_WANT_ALL);
30 ASSERT_EQ(2u, pieces.size()); 32 ASSERT_EQ(2u, pieces.size());
31 buffer = pieces[1]; 33 buffer = pieces[1];
32 EXPECT_EQ("", pieces[0]); 34 EXPECT_EQ("", pieces[0]);
33 35
34 base::SplitStringUsingSubstr(buffer, ") AppleWebKit/", &pieces); 36 pieces = base::SplitStringUsingSubstr(buffer, ") AppleWebKit/",
37 base::TRIM_WHITESPACE,
38 base::SPLIT_WANT_ALL);
35 ASSERT_EQ(2u, pieces.size()); 39 ASSERT_EQ(2u, pieces.size());
36 buffer = pieces[1]; 40 buffer = pieces[1];
37 std::string os_str = pieces[0]; 41 std::string os_str = pieces[0];
38 42
39 base::SplitStringUsingSubstr(buffer, " (KHTML, like Gecko) ", &pieces); 43 pieces = base::SplitStringUsingSubstr(buffer, " (KHTML, like Gecko) ",
44 base::TRIM_WHITESPACE,
45 base::SPLIT_WANT_ALL);
40 ASSERT_EQ(2u, pieces.size()); 46 ASSERT_EQ(2u, pieces.size());
41 buffer = pieces[1]; 47 buffer = pieces[1];
42 std::string webkit_version_str = pieces[0]; 48 std::string webkit_version_str = pieces[0];
43 49
44 base::SplitStringUsingSubstr(buffer, " Safari/", &pieces); 50 pieces = base::SplitStringUsingSubstr(buffer, " Safari/",
51 base::TRIM_WHITESPACE,
52 base::SPLIT_WANT_ALL);
45 ASSERT_EQ(2u, pieces.size()); 53 ASSERT_EQ(2u, pieces.size());
46 std::string product_str = pieces[0]; 54 std::string product_str = pieces[0];
47 std::string safari_version_str = pieces[1]; 55 std::string safari_version_str = pieces[1];
48 56
49 // Not sure what can be done to better check the OS string, since it's highly 57 // Not sure what can be done to better check the OS string, since it's highly
50 // platform-dependent. 58 // platform-dependent.
51 EXPECT_FALSE(os_str.empty()); 59 EXPECT_FALSE(os_str.empty());
52 60
53 // Check that the version numbers match. 61 // Check that the version numbers match.
54 EXPECT_FALSE(webkit_version_str.empty()); 62 EXPECT_FALSE(webkit_version_str.empty());
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 url::Component(0, strlen(extensions::kExtensionScheme)))); 233 url::Component(0, strlen(extensions::kExtensionScheme))));
226 234
227 GURL extension_url( 235 GURL extension_url(
228 "chrome-extension://abcdefghijklmnopqrstuvwxyzabcdef/foo.html"); 236 "chrome-extension://abcdefghijklmnopqrstuvwxyzabcdef/foo.html");
229 url::Origin origin(extension_url); 237 url::Origin origin(extension_url);
230 EXPECT_EQ("chrome-extension://abcdefghijklmnopqrstuvwxyzabcdef", 238 EXPECT_EQ("chrome-extension://abcdefghijklmnopqrstuvwxyzabcdef",
231 origin.Serialize()); 239 origin.Serialize());
232 } 240 }
233 241
234 } // namespace chrome_common 242 } // namespace chrome_common
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/autofill_options_handler.cc ('k') | extensions/renderer/extensions_render_frame_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698