OLD | NEW |
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 "net/cookies/cookie_store_unittest.h" | 5 #include "net/cookies/cookie_store_unittest.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | |
12 #include "base/bind.h" | 11 #include "base/bind.h" |
13 #include "base/location.h" | 12 #include "base/location.h" |
14 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
16 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
17 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
18 #include "base/metrics/histogram_samples.h" | 17 #include "base/metrics/histogram_samples.h" |
19 #include "base/single_thread_task_runner.h" | 18 #include "base/single_thread_task_runner.h" |
20 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
21 #include "base/strings/string_piece.h" | 20 #include "base/strings/string_piece.h" |
(...skipping 1907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1929 http_www_google_.Format(".%D"), "/", Time(), false, false, false, | 1928 http_www_google_.Format(".%D"), "/", Time(), false, false, false, |
1930 COOKIE_PRIORITY_DEFAULT)); | 1929 COOKIE_PRIORITY_DEFAULT)); |
1931 EXPECT_TRUE(SetCookieWithDetails( | 1930 EXPECT_TRUE(SetCookieWithDetails( |
1932 cm.get(), http_www_google_.url(), "setCookieWithDetails3", "A", | 1931 cm.get(), http_www_google_.url(), "setCookieWithDetails3", "A", |
1933 http_www_google_.Format(".%D"), "/", Time(), false, false, false, | 1932 http_www_google_.Format(".%D"), "/", Time(), false, false, false, |
1934 COOKIE_PRIORITY_DEFAULT)); | 1933 COOKIE_PRIORITY_DEFAULT)); |
1935 | 1934 |
1936 // Now we check | 1935 // Now we check |
1937 CookieList cookie_list(GetAllCookies(cm.get())); | 1936 CookieList cookie_list(GetAllCookies(cm.get())); |
1938 EXPECT_EQ(9u, cookie_list.size()); | 1937 EXPECT_EQ(9u, cookie_list.size()); |
1939 typedef std::map<int64, CanonicalCookie> TimeCookieMap; | 1938 typedef std::map<int64_t, CanonicalCookie> TimeCookieMap; |
1940 TimeCookieMap check_map; | 1939 TimeCookieMap check_map; |
1941 for (CookieList::const_iterator it = cookie_list.begin(); | 1940 for (CookieList::const_iterator it = cookie_list.begin(); |
1942 it != cookie_list.end(); it++) { | 1941 it != cookie_list.end(); it++) { |
1943 const int64 creation_date = it->CreationDate().ToInternalValue(); | 1942 const int64_t creation_date = it->CreationDate().ToInternalValue(); |
1944 TimeCookieMap::const_iterator existing_cookie_it( | 1943 TimeCookieMap::const_iterator existing_cookie_it( |
1945 check_map.find(creation_date)); | 1944 check_map.find(creation_date)); |
1946 EXPECT_TRUE(existing_cookie_it == check_map.end()) | 1945 EXPECT_TRUE(existing_cookie_it == check_map.end()) |
1947 << "Cookie " << it->Name() << " has same creation date (" | 1946 << "Cookie " << it->Name() << " has same creation date (" |
1948 << it->CreationDate().ToInternalValue() | 1947 << it->CreationDate().ToInternalValue() |
1949 << ") as previously entered cookie " | 1948 << ") as previously entered cookie " |
1950 << existing_cookie_it->second.Name(); | 1949 << existing_cookie_it->second.Name(); |
1951 | 1950 |
1952 if (existing_cookie_it == check_map.end()) { | 1951 if (existing_cookie_it == check_map.end()) { |
1953 check_map.insert( | 1952 check_map.insert( |
(...skipping 1619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3573 monster()->AddCallbackForCookie( | 3572 monster()->AddCallbackForCookie( |
3574 test_url_, "abc", | 3573 test_url_, "abc", |
3575 base::Bind(&RecordCookieChanges, &cookies1, nullptr))); | 3574 base::Bind(&RecordCookieChanges, &cookies1, nullptr))); |
3576 SetCookie(monster(), test_url_, "abc=def"); | 3575 SetCookie(monster(), test_url_, "abc=def"); |
3577 base::MessageLoop::current()->RunUntilIdle(); | 3576 base::MessageLoop::current()->RunUntilIdle(); |
3578 EXPECT_EQ(1U, cookies0.size()); | 3577 EXPECT_EQ(1U, cookies0.size()); |
3579 EXPECT_EQ(1U, cookies0.size()); | 3578 EXPECT_EQ(1U, cookies0.size()); |
3580 } | 3579 } |
3581 | 3580 |
3582 } // namespace net | 3581 } // namespace net |
OLD | NEW |