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

Unified Diff: chrome_frame/test/http_negotiate_unittest.cc

Issue 2825053: Simple initial test for AppendCFUserAgentString. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome_frame/test/http_negotiate_unittest.cc
===================================================================
--- chrome_frame/test/http_negotiate_unittest.cc (revision 52727)
+++ chrome_frame/test/http_negotiate_unittest.cc (working copy)
@@ -273,3 +273,34 @@
}
}
+using testing::AllOf;
+using testing::ContainsRegex;
+using testing::HasSubstr;
+
+TEST(AppendUserAgent, Append) {
+ EXPECT_THAT(AppendCFUserAgentString(NULL, NULL),
+ testing::ContainsRegex("User-Agent:.+chromeframe.+\r\n"));
+
+ // Check Http headers are reasonably parsed.
+ EXPECT_THAT(AppendCFUserAgentString(L"Bad User-Agent: Age Tuners;\r\n", NULL),
+ AllOf(ContainsRegex("User-Agent:.+chromeframe.+\r\n"),
+ testing::Not(testing::HasSubstr("Age Tuners"))));
+
+ // Honor headers User-Agent, if additional headers does not specify one.
+ EXPECT_THAT(AppendCFUserAgentString(L"User-Agent: A Tense Rug;\r\n", NULL),
+ ContainsRegex("User-Agent: A Tense Rug; chromeframe.+\r\n"));
+
+ // Honor additional headers User-Agent.
+ EXPECT_THAT(AppendCFUserAgentString(L"User-Agent: Near Guest;\r\n",
+ L"User-Agent: Rat see Gun;\r\n"),
+ ContainsRegex("User-Agent: Rat see Gun; chromeframe.+\r\n"));
+
+ // Check additional headers are preserved.
+ EXPECT_THAT(AppendCFUserAgentString(NULL,
+ L"Authorization: A Zoo That I Ruin\r\n"
+ L"User-Agent: Get a Nurse;\r\n"
+ L"Accept-Language: Cleanup a Cat Egg\r\n"),
+ AllOf(ContainsRegex("User-Agent: Get a Nurse; chromeframe.+\r\n"),
tommi (sloooow) - chröme 2010/07/17 01:13:10 this one is a duplicate. I'm confused - did you m
+ HasSubstr("Authorization: A Zoo That I Ruin\r\n"),
+ HasSubstr("Accept-Language: Cleanup a Cat Egg\r\n")));
+}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698