| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 "base/file_path.h" | 5 #include "base/file_path.h" |
| 6 #include "base/stl_util.h" | 6 #include "base/stl_util.h" |
| 7 #include "base/test/test_timeouts.h" | 7 #include "base/test/test_timeouts.h" |
| 8 #include "base/test/thread_test_helper.h" | 8 #include "base/test/thread_test_helper.h" |
| 9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
| 10 #include "chrome/browser/net/sqlite_persistent_cookie_store.h" | 10 #include "chrome/browser/net/sqlite_persistent_cookie_store.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 // puts the cookie's value in |cookie_value| and sets |has_cookie| to true. | 46 // puts the cookie's value in |cookie_value| and sets |has_cookie| to true. |
| 47 // Sets |has_cookie| to false if the |cookie| wasn't found. | 47 // Sets |has_cookie| to false if the |cookie| wasn't found. |
| 48 static void GetCookie( | 48 static void GetCookie( |
| 49 const FilePath& user_data_dir, | 49 const FilePath& user_data_dir, |
| 50 const net::CookieMonster::CanonicalCookie& cookie, | 50 const net::CookieMonster::CanonicalCookie& cookie, |
| 51 bool* has_cookie, | 51 bool* has_cookie, |
| 52 std::string* cookie_value, | 52 std::string* cookie_value, |
| 53 const scoped_refptr<base::ThreadTestHelper>& thread_helper) { | 53 const scoped_refptr<base::ThreadTestHelper>& thread_helper) { |
| 54 scoped_refptr<SQLitePersistentCookieStore> cookie_store( | 54 scoped_refptr<SQLitePersistentCookieStore> cookie_store( |
| 55 new SQLitePersistentCookieStore( | 55 new SQLitePersistentCookieStore( |
| 56 user_data_dir.AppendASCII(chrome::kNotSignedInProfile) | 56 user_data_dir.AppendASCII(chrome::kInitialProfile) |
| 57 .Append(chrome::kCookieFilename))); | 57 .Append(chrome::kCookieFilename))); |
| 58 HERE(1); | 58 HERE(1); |
| 59 std::vector<net::CookieMonster::CanonicalCookie*> cookies; | 59 std::vector<net::CookieMonster::CanonicalCookie*> cookies; |
| 60 ASSERT_TRUE(cookie_store->Load(&cookies)); | 60 ASSERT_TRUE(cookie_store->Load(&cookies)); |
| 61 HERE(2); | 61 HERE(2); |
| 62 *has_cookie = false; | 62 *has_cookie = false; |
| 63 for (size_t i = 0; i < cookies.size(); ++i) { | 63 for (size_t i = 0; i < cookies.size(); ++i) { |
| 64 if (cookies[i]->IsEquivalent(cookie)) { | 64 if (cookies[i]->IsEquivalent(cookie)) { |
| 65 *has_cookie = true; | 65 *has_cookie = true; |
| 66 *cookie_value = cookies[i]->Value(); | 66 *cookie_value = cookies[i]->Value(); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 TestTimeouts::action_max_timeout_ms(), &exit_code)); | 151 TestTimeouts::action_max_timeout_ms(), &exit_code)); |
| 152 HERE(24); | 152 HERE(24); |
| 153 EXPECT_EQ(0, exit_code); // Expect a clean shutdown. | 153 EXPECT_EQ(0, exit_code); // Expect a clean shutdown. |
| 154 | 154 |
| 155 // Read the cookie and check that it has the expected value. | 155 // Read the cookie and check that it has the expected value. |
| 156 GetCookie(user_data_dir(), cookie, &has_cookie, &cookie_value, thread_helper); | 156 GetCookie(user_data_dir(), cookie, &has_cookie, &cookie_value, thread_helper); |
| 157 HERE(25); | 157 HERE(25); |
| 158 EXPECT_TRUE(has_cookie); | 158 EXPECT_TRUE(has_cookie); |
| 159 EXPECT_EQ("ohyeah", cookie_value); | 159 EXPECT_EQ("ohyeah", cookie_value); |
| 160 } | 160 } |
| OLD | NEW |