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

Side by Side Diff: net/cookies/parsed_cookie_unittest.cc

Issue 14113014: Adding Priority field to cookies. (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 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
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 <string> 5 #include <string>
6 6
7 #include "net/cookies/cookie_constants.h"
7 #include "net/cookies/parsed_cookie.h" 8 #include "net/cookies/parsed_cookie.h"
8 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
9 10
10 namespace net { 11 namespace net {
11 12
12 namespace { 13 namespace {
13 14
14 class ParsedCookieTest : public testing::Test { }; 15 class ParsedCookieTest : public testing::Test { };
15 16
16 } // namespace 17 } // namespace
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 EXPECT_TRUE(pc.SetValue("value2")); 366 EXPECT_TRUE(pc.SetValue("value2"));
366 EXPECT_FALSE(pc.HasDomain()); 367 EXPECT_FALSE(pc.HasDomain());
367 EXPECT_FALSE(pc.HasPath()); 368 EXPECT_FALSE(pc.HasPath());
368 EXPECT_FALSE(pc.HasExpires()); 369 EXPECT_FALSE(pc.HasExpires());
369 EXPECT_FALSE(pc.HasMaxAge()); 370 EXPECT_FALSE(pc.HasMaxAge());
370 EXPECT_FALSE(pc.IsSecure()); 371 EXPECT_FALSE(pc.IsSecure());
371 EXPECT_FALSE(pc.IsHttpOnly()); 372 EXPECT_FALSE(pc.IsHttpOnly());
372 EXPECT_EQ("name2=value2", pc.ToCookieLine()); 373 EXPECT_EQ("name2=value2", pc.ToCookieLine());
373 } 374 }
374 375
376 TEST(ParsedCookieTest, SetPriority) {
377 ParsedCookie pc("name=value");
378 EXPECT_TRUE(pc.IsValid());
379
380 // Test basic assumptions in CookiePriority.
381 EXPECT_EQ(PRIORITY_DEFAULT, PRIORITY_MEDIUM);
382 EXPECT_EQ("Low", PriorityToString(PRIORITY_LOW));
383 EXPECT_EQ("Medium", PriorityToString(PRIORITY_MEDIUM));
384 EXPECT_EQ("High", PriorityToString(PRIORITY_HIGH));
385
386 EXPECT_EQ("name=value", pc.ToCookieLine());
387 EXPECT_EQ(PRIORITY_DEFAULT, pc.Priority());
388
389 // Test each priority, expect case-insensitive compare.
390 EXPECT_TRUE(pc.SetPriority("high"));
391 EXPECT_EQ("name=value; priority=high", pc.ToCookieLine());
392 EXPECT_EQ(PRIORITY_HIGH, pc.Priority());
393
394 EXPECT_TRUE(pc.SetPriority("mEDium"));
395 EXPECT_EQ("name=value; priority=mEDium", pc.ToCookieLine());
396 EXPECT_EQ(PRIORITY_MEDIUM, pc.Priority());
397
398 EXPECT_TRUE(pc.SetPriority("LOW"));
399 EXPECT_EQ("name=value; priority=LOW", pc.ToCookieLine());
400 EXPECT_EQ(PRIORITY_LOW, pc.Priority());
401
402 // Interpret invalid priority values as PRIORITY_DEFAULT.
403 EXPECT_TRUE(pc.SetPriority("Blah"));
404 EXPECT_EQ("name=value; priority=Blah", pc.ToCookieLine());
405 EXPECT_EQ(PRIORITY_DEFAULT, pc.Priority());
406
407 EXPECT_TRUE(pc.SetPriority("Lowerest"));
408 EXPECT_EQ("name=value; priority=Lowerest", pc.ToCookieLine());
409 EXPECT_EQ(PRIORITY_DEFAULT, pc.Priority());
410
411 EXPECT_TRUE(pc.SetPriority(""));
412 EXPECT_EQ("name=value", pc.ToCookieLine());
413 EXPECT_EQ(PRIORITY_DEFAULT, pc.Priority());
414 }
415
375 } // namespace net 416 } // namespace net
OLDNEW
« net/cookies/cookie_constants.cc ('K') | « net/cookies/parsed_cookie.cc ('k') | net/net.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698