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

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

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

Powered by Google App Engine
This is Rietveld 408576698