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

Side by Side Diff: chrome/test/webdriver/http_response_unittest.cc

Issue 23526047: Delete old chromedriver code, and remove mongoose webserver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 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 | Annotate | Revision Log
« no previous file with comments | « chrome/test/webdriver/http_response.cc ('k') | chrome/test/webdriver/keycode_text_conversion.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 (c) 2011 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 #include "chrome/test/webdriver/http_response.h"
6 #include "testing/gtest/include/gtest/gtest.h"
7
8 namespace webdriver {
9
10 namespace {
11
12 void ExpectHeaderValue(const HttpResponse& response, const std::string& name,
13 const std::string& expected_value) {
14 std::string actual_value;
15 EXPECT_TRUE(response.GetHeader(name, &actual_value));
16 EXPECT_EQ(expected_value, actual_value);
17 }
18
19 } // namespace
20
21 TEST(HttpResponseTest, AddingHeaders) {
22 HttpResponse response;
23
24 response.AddHeader("FOO", "a");
25 ExpectHeaderValue(response, "foo", "a");
26
27 // Headers should be case insensitive.
28 response.AddHeader("fOo", "b,c");
29 response.AddHeader("FoO", "d");
30 ExpectHeaderValue(response, "foo", "a,b,c,d");
31 }
32
33 TEST(HttpResponseTest, RemovingHeaders) {
34 HttpResponse response;
35
36 ASSERT_FALSE(response.RemoveHeader("I-Am-Not-There"));
37
38 ASSERT_FALSE(response.GetHeader("foo", NULL));
39 response.AddHeader("foo", "bar");
40 ASSERT_TRUE(response.GetHeader("foo", NULL));
41 ASSERT_TRUE(response.RemoveHeader("foo"));
42 ASSERT_FALSE(response.GetHeader("foo", NULL));
43 }
44
45 TEST(HttpResponseTest, CanClearAllHeaders) {
46 HttpResponse response;
47 response.AddHeader("food", "cheese");
48 response.AddHeader("color", "red");
49
50 ExpectHeaderValue(response, "food", "cheese");
51 ExpectHeaderValue(response, "color", "red");
52
53 response.ClearHeaders();
54 EXPECT_FALSE(response.GetHeader("food", NULL));
55 EXPECT_FALSE(response.GetHeader("color", NULL));
56 }
57
58 TEST(HttpResponseTest, CanSetMimeType) {
59 HttpResponse response;
60
61 response.SetMimeType("application/json");
62 ExpectHeaderValue(response, "content-type", "application/json");
63
64 response.SetMimeType("text/html");
65 ExpectHeaderValue(response, "content-type", "text/html");
66 }
67
68 TEST(HttpResponseTest, GetData) {
69 HttpResponse response;
70 response.set_body("my body");
71 std::string data;
72 response.GetData(&data);
73 const char* expected =
74 "HTTP/1.1 200 OK\r\n"
75 "content-length:7\r\n"
76 "\r\n"
77 "my body";
78 ASSERT_STREQ(expected, data.c_str());
79 }
80
81 } // namespace webdriver
OLDNEW
« no previous file with comments | « chrome/test/webdriver/http_response.cc ('k') | chrome/test/webdriver/keycode_text_conversion.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698