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/test/testing_profile.h" | 5 #include "chrome/test/testing_profile.h" |
6 #include "content/browser/browser_thread.h" | 6 #include "content/browser/browser_thread.h" |
7 #include "content/browser/in_process_webkit/dom_storage_context.h" | 7 #include "content/browser/in_process_webkit/dom_storage_context.h" |
8 #include "content/browser/in_process_webkit/webkit_context.h" | 8 #include "content/browser/in_process_webkit/webkit_context.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
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.GetSpecialStoragePolicy(), | 35 profile.GetSpecialStoragePolicy(), |
36 false)); | 36 false, NULL, NULL)); |
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.GetSpecialStoragePolicy(), | 42 profile.GetSpecialStoragePolicy(), |
43 false)); | 43 false, NULL, NULL)); |
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.GetSpecialStoragePolicy(), | 58 profile.GetSpecialStoragePolicy(), |
59 false)); | 59 false, NULL, NULL)); |
60 MockDOMStorageContext* mock_context = new MockDOMStorageContext( | 60 MockDOMStorageContext* mock_context = new MockDOMStorageContext( |
61 context.get(), profile.GetSpecialStoragePolicy()); | 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 } |
OLD | NEW |