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 "chrome/browser/browsing_data_cookie_helper.h" | 5 #include "chrome/browser/browsing_data_cookie_helper.h" |
6 | 6 |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
11 #include "chrome/test/base/testing_browser_process_test.h" | |
12 #include "chrome/test/base/testing_profile.h" | 11 #include "chrome/test/base/testing_profile.h" |
13 #include "content/browser/browser_thread.h" | 12 #include "content/browser/browser_thread.h" |
14 #include "net/url_request/url_request_context_getter.h" | 13 #include "net/url_request/url_request_context_getter.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
16 | 15 |
17 namespace { | 16 namespace { |
18 | 17 |
19 class BrowsingDataCookieHelperTest : public TestingBrowserProcessTest { | 18 class BrowsingDataCookieHelperTest : public testing::Test { |
20 public: | 19 public: |
21 void SetUpOnIOThread(base::WaitableEvent* io_setup_complete) { | 20 void SetUpOnIOThread(base::WaitableEvent* io_setup_complete) { |
22 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 21 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
23 // This is a workaround for a bug in the TestingProfile. | 22 // This is a workaround for a bug in the TestingProfile. |
24 // The URLRequestContext will be created by GetCookieMonster on the UI | 23 // The URLRequestContext will be created by GetCookieMonster on the UI |
25 // thread, if it does not already exist. But it must be created on the IO | 24 // thread, if it does not already exist. But it must be created on the IO |
26 // thread or else it will DCHECK upon destruction. | 25 // thread or else it will DCHECK upon destruction. |
27 // Force it to be created here. | 26 // Force it to be created here. |
28 testing_profile_->CreateRequestContext(); | 27 testing_profile_->CreateRequestContext(); |
29 testing_profile_->GetRequestContext()->GetURLRequestContext(); | 28 testing_profile_->GetRequestContext()->GetURLRequestContext(); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 new net::CookieMonster::CanonicalCookie(url_google, pc)); | 194 new net::CookieMonster::CanonicalCookie(url_google, pc)); |
196 cookies.push_back(*cookie); | 195 cookies.push_back(*cookie); |
197 | 196 |
198 helper->AddReadCookies(url_google, cookies); | 197 helper->AddReadCookies(url_google, cookies); |
199 ASSERT_FALSE(helper->empty()); | 198 ASSERT_FALSE(helper->empty()); |
200 helper->Reset(); | 199 helper->Reset(); |
201 ASSERT_TRUE(helper->empty()); | 200 ASSERT_TRUE(helper->empty()); |
202 } | 201 } |
203 | 202 |
204 } // namespace | 203 } // namespace |
OLD | NEW |