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

Side by Side Diff: content/browser/in_process_webkit/webkit_context_unittest.cc

Issue 8400060: Switch content tests to use BrowserThreadImpl directly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to lkgr Created 9 years, 1 month 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
OLDNEW
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 "content/browser/browser_thread_impl.h"
5 #include "content/browser/in_process_webkit/dom_storage_context.h" 6 #include "content/browser/in_process_webkit/dom_storage_context.h"
6 #include "content/browser/in_process_webkit/webkit_context.h" 7 #include "content/browser/in_process_webkit/webkit_context.h"
7 #include "content/test/test_browser_context.h" 8 #include "content/test/test_browser_context.h"
8 #include "content/test/test_browser_thread.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 using content::BrowserThreadImpl;
12
11 class MockDOMStorageContext : public DOMStorageContext { 13 class MockDOMStorageContext : public DOMStorageContext {
12 public: 14 public:
13 MockDOMStorageContext(WebKitContext* webkit_context, 15 MockDOMStorageContext(WebKitContext* webkit_context,
14 quota::SpecialStoragePolicy* special_storage_policy) 16 quota::SpecialStoragePolicy* special_storage_policy)
15 : DOMStorageContext(webkit_context, special_storage_policy), 17 : DOMStorageContext(webkit_context, special_storage_policy),
16 purge_count_(0) { 18 purge_count_(0) {
17 } 19 }
18 20
19 virtual void PurgeMemory() { 21 virtual void PurgeMemory() {
20 EXPECT_FALSE(BrowserThread::CurrentlyOn(BrowserThread::UI)); 22 EXPECT_FALSE(BrowserThread::CurrentlyOn(BrowserThread::UI));
(...skipping 19 matching lines...) Expand all
40 browser_context.IsOffTheRecord(), browser_context.GetPath(), 42 browser_context.IsOffTheRecord(), browser_context.GetPath(),
41 NULL, false, NULL, NULL)); 43 NULL, false, NULL, NULL));
42 EXPECT_TRUE(context1->data_path() == context2->data_path()); 44 EXPECT_TRUE(context1->data_path() == context2->data_path());
43 EXPECT_TRUE(context1->is_incognito() == context2->is_incognito()); 45 EXPECT_TRUE(context1->is_incognito() == context2->is_incognito());
44 } 46 }
45 47
46 TEST(WebKitContextTest, PurgeMemory) { 48 TEST(WebKitContextTest, PurgeMemory) {
47 // Start up a WebKit thread for the WebKitContext to call the 49 // Start up a WebKit thread for the WebKitContext to call the
48 // DOMStorageContext on. 50 // DOMStorageContext on.
49 MessageLoop message_loop(MessageLoop::TYPE_DEFAULT); 51 MessageLoop message_loop(MessageLoop::TYPE_DEFAULT);
50 content::TestBrowserThread webkit_thread(BrowserThread::WEBKIT, 52 BrowserThreadImpl webkit_thread(BrowserThread::WEBKIT, &message_loop);
51 &message_loop);
52 53
53 { 54 {
54 // Create the contexts. 55 // Create the contexts.
55 TestBrowserContext browser_context; 56 TestBrowserContext browser_context;
56 scoped_refptr<WebKitContext> context(new WebKitContext( 57 scoped_refptr<WebKitContext> context(new WebKitContext(
57 browser_context.IsOffTheRecord(), browser_context.GetPath(), 58 browser_context.IsOffTheRecord(), browser_context.GetPath(),
58 NULL, false, NULL, NULL)); 59 NULL, false, NULL, NULL));
59 MockDOMStorageContext* mock_context = new MockDOMStorageContext( 60 MockDOMStorageContext* mock_context = new MockDOMStorageContext(
60 context.get(), NULL); 61 context.get(), NULL);
61 // Takes ownership. 62 // Takes ownership.
62 context->set_dom_storage_context_for_testing(mock_context); 63 context->set_dom_storage_context_for_testing(mock_context);
63 64
64 // Ensure PurgeMemory() calls our mock object on the right thread. 65 // Ensure PurgeMemory() calls our mock object on the right thread.
65 EXPECT_EQ(0, mock_context->purge_count()); 66 EXPECT_EQ(0, mock_context->purge_count());
66 context->PurgeMemory(); 67 context->PurgeMemory();
67 MessageLoop::current()->RunAllPending(); 68 MessageLoop::current()->RunAllPending();
68 EXPECT_EQ(1, mock_context->purge_count()); 69 EXPECT_EQ(1, mock_context->purge_count());
69 } 70 }
70 // WebKitContext's destructor posts stuff to the webkit thread. Let 71 // WebKitContext's destructor posts stuff to the webkit thread. Let
71 // WebKitContext go out of scope here before processing WebKitContext's 72 // WebKitContext go out of scope here before processing WebKitContext's
72 // clean-up tasks. 73 // clean-up tasks.
73 MessageLoop::current()->RunAllPending(); 74 MessageLoop::current()->RunAllPending();
74 } 75 }
OLDNEW
« no previous file with comments | « content/browser/in_process_webkit/indexed_db_quota_client_unittest.cc ('k') | content/browser/plugin_loader_posix_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698