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

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

Issue 6693054: Get rid of extensions dependency from content\browser. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 months 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
« no previous file with comments | « content/browser/content_browser_client.cc ('k') | content/browser/plugin_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/extensions/extension_special_storage_policy.h"
6 #include "chrome/test/testing_profile.h" 5 #include "chrome/test/testing_profile.h"
7 #include "content/browser/browser_thread.h" 6 #include "content/browser/browser_thread.h"
8 #include "content/browser/in_process_webkit/dom_storage_context.h" 7 #include "content/browser/in_process_webkit/dom_storage_context.h"
9 #include "content/browser/in_process_webkit/webkit_context.h" 8 #include "content/browser/in_process_webkit/webkit_context.h"
10 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
11 10
12 class MockDOMStorageContext : public DOMStorageContext { 11 class MockDOMStorageContext : public DOMStorageContext {
13 public: 12 public:
14 explicit MockDOMStorageContext(WebKitContext* webkit_context) 13 MockDOMStorageContext(WebKitContext* webkit_context,
15 : DOMStorageContext(webkit_context, new ExtensionSpecialStoragePolicy), 14 quota::SpecialStoragePolicy* special_storage_policy)
15 : DOMStorageContext(webkit_context, special_storage_policy),
16 purge_count_(0) { 16 purge_count_(0) {
17 } 17 }
18 18
19 virtual void PurgeMemory() { 19 virtual void PurgeMemory() {
20 EXPECT_FALSE(BrowserThread::CurrentlyOn(BrowserThread::UI)); 20 EXPECT_FALSE(BrowserThread::CurrentlyOn(BrowserThread::UI));
21 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); 21 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
22 ++purge_count_; 22 ++purge_count_;
23 } 23 }
24 24
25 int purge_count() const { return purge_count_; } 25 int purge_count() const { return purge_count_; }
26 26
27 private: 27 private:
28 int purge_count_; 28 int purge_count_;
29 }; 29 };
30 30
31 TEST(WebKitContextTest, Basic) { 31 TEST(WebKitContextTest, Basic) {
32 TestingProfile profile; 32 TestingProfile profile;
33 scoped_refptr<WebKitContext> context1(new WebKitContext( 33 scoped_refptr<WebKitContext> context1(new WebKitContext(
34 profile.IsOffTheRecord(), profile.GetPath(), 34 profile.IsOffTheRecord(), profile.GetPath(),
35 profile.GetExtensionSpecialStoragePolicy(), 35 profile.GetSpecialStoragePolicy(),
36 false)); 36 false));
37 EXPECT_TRUE(profile.GetPath() == context1->data_path()); 37 EXPECT_TRUE(profile.GetPath() == context1->data_path());
38 EXPECT_TRUE(profile.IsOffTheRecord() == context1->is_incognito()); 38 EXPECT_TRUE(profile.IsOffTheRecord() == context1->is_incognito());
39 39
40 scoped_refptr<WebKitContext> context2(new WebKitContext( 40 scoped_refptr<WebKitContext> context2(new WebKitContext(
41 profile.IsOffTheRecord(), profile.GetPath(), 41 profile.IsOffTheRecord(), profile.GetPath(),
42 profile.GetExtensionSpecialStoragePolicy(), 42 profile.GetSpecialStoragePolicy(),
43 false)); 43 false));
44 EXPECT_TRUE(context1->data_path() == context2->data_path()); 44 EXPECT_TRUE(context1->data_path() == context2->data_path());
45 EXPECT_TRUE(context1->is_incognito() == context2->is_incognito()); 45 EXPECT_TRUE(context1->is_incognito() == context2->is_incognito());
46 } 46 }
47 47
48 TEST(WebKitContextTest, PurgeMemory) { 48 TEST(WebKitContextTest, PurgeMemory) {
49 // Start up a WebKit thread for the WebKitContext to call the 49 // Start up a WebKit thread for the WebKitContext to call the
50 // DOMStorageContext on. 50 // DOMStorageContext on.
51 BrowserThread webkit_thread(BrowserThread::WEBKIT); 51 BrowserThread webkit_thread(BrowserThread::WEBKIT);
52 webkit_thread.Start(); 52 webkit_thread.Start();
53 53
54 // Create the contexts. 54 // Create the contexts.
55 TestingProfile profile; 55 TestingProfile profile;
56 scoped_refptr<WebKitContext> context(new WebKitContext( 56 scoped_refptr<WebKitContext> context(new WebKitContext(
57 profile.IsOffTheRecord(), profile.GetPath(), 57 profile.IsOffTheRecord(), profile.GetPath(),
58 profile.GetExtensionSpecialStoragePolicy(), 58 profile.GetSpecialStoragePolicy(),
59 false)); 59 false));
60 MockDOMStorageContext* mock_context = 60 MockDOMStorageContext* mock_context = new MockDOMStorageContext(
61 new MockDOMStorageContext(context.get()); 61 context.get(), profile.GetSpecialStoragePolicy());
62 context->set_dom_storage_context(mock_context); // Takes ownership. 62 context->set_dom_storage_context(mock_context); // Takes ownership.
63 63
64 // Ensure PurgeMemory() calls our mock object on the right thread. 64 // Ensure PurgeMemory() calls our mock object on the right thread.
65 EXPECT_EQ(0, mock_context->purge_count()); 65 EXPECT_EQ(0, mock_context->purge_count());
66 context->PurgeMemory(); 66 context->PurgeMemory();
67 webkit_thread.Stop(); // Blocks until all tasks are complete. 67 webkit_thread.Stop(); // Blocks until all tasks are complete.
68 EXPECT_EQ(1, mock_context->purge_count()); 68 EXPECT_EQ(1, mock_context->purge_count());
69 } 69 }
OLDNEW
« no previous file with comments | « content/browser/content_browser_client.cc ('k') | content/browser/plugin_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698