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/extensions/extension_service_unittest.h" | 5 #include "chrome/browser/extensions/extension_service_unittest.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 2740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2751 // Create local storage. We only simulate this by creating the backing file | 2751 // Create local storage. We only simulate this by creating the backing file |
2752 // since webkit is not initialized. | 2752 // since webkit is not initialized. |
2753 DOMStorageContext* context = | 2753 DOMStorageContext* context = |
2754 profile_->GetWebKitContext()->dom_storage_context(); | 2754 profile_->GetWebKitContext()->dom_storage_context(); |
2755 FilePath lso_path = context->GetLocalStorageFilePath(origin_id); | 2755 FilePath lso_path = context->GetLocalStorageFilePath(origin_id); |
2756 EXPECT_TRUE(file_util::CreateDirectory(lso_path.DirName())); | 2756 EXPECT_TRUE(file_util::CreateDirectory(lso_path.DirName())); |
2757 EXPECT_EQ(0, file_util::WriteFile(lso_path, NULL, 0)); | 2757 EXPECT_EQ(0, file_util::WriteFile(lso_path, NULL, 0)); |
2758 EXPECT_TRUE(file_util::PathExists(lso_path)); | 2758 EXPECT_TRUE(file_util::PathExists(lso_path)); |
2759 | 2759 |
2760 // Create indexed db. Again, it is enough to only simulate this by creating | 2760 // Create indexed db. Again, it is enough to only simulate this by creating |
2761 // the file on the disk. | 2761 // the file on the disk. |
Mike West
2011/08/24 08:09:00
Nit: You're no longer explicitly creating a file o
| |
2762 IndexedDBContext* idb_context = | 2762 IndexedDBContext* idb_context = |
2763 profile_->GetWebKitContext()->indexed_db_context(); | 2763 profile_->GetWebKitContext()->indexed_db_context(); |
2764 FilePath idb_path = idb_context->GetIndexedDBFilePath(origin_id); | 2764 FilePath idb_path = idb_context->GetIndexedDBFilePath(origin_id); |
2765 EXPECT_TRUE(file_util::CreateDirectory(idb_path.DirName())); | 2765 EXPECT_TRUE(file_util::CreateDirectory(idb_path)); |
2766 EXPECT_EQ(0, file_util::WriteFile(idb_path, NULL, 0)); | 2766 EXPECT_TRUE(file_util::DirectoryExists(idb_path)); |
2767 EXPECT_TRUE(file_util::PathExists(idb_path)); | |
2768 | 2767 |
2769 // Uninstall the extension. | 2768 // Uninstall the extension. |
2770 service_->UninstallExtension(good_crx, false, NULL); | 2769 service_->UninstallExtension(good_crx, false, NULL); |
2771 loop_.RunAllPending(); | 2770 loop_.RunAllPending(); |
2772 | 2771 |
2773 // Check that the cookie is gone. | 2772 // Check that the cookie is gone. |
2774 cookie_monster->GetAllCookiesForURLAsync( | 2773 cookie_monster->GetAllCookiesForURLAsync( |
2775 ext_url, | 2774 ext_url, |
2776 base::Bind(&ExtensionCookieCallback::GetAllCookiesCallback, | 2775 base::Bind(&ExtensionCookieCallback::GetAllCookiesCallback, |
2777 base::Unretained(&callback))); | 2776 base::Unretained(&callback))); |
2778 loop_.RunAllPending(); | 2777 loop_.RunAllPending(); |
2779 EXPECT_EQ(0U, callback.list_.size()); | 2778 EXPECT_EQ(0U, callback.list_.size()); |
2780 | 2779 |
2781 // The database should have vanished as well. | 2780 // The database should have vanished as well. |
2782 origins.clear(); | 2781 origins.clear(); |
2783 db_tracker->GetAllOriginsInfo(&origins); | 2782 db_tracker->GetAllOriginsInfo(&origins); |
2784 EXPECT_EQ(0U, origins.size()); | 2783 EXPECT_EQ(0U, origins.size()); |
2785 | 2784 |
2786 // Check that the LSO file has been removed. | 2785 // Check that the LSO file has been removed. |
2787 EXPECT_FALSE(file_util::PathExists(lso_path)); | 2786 EXPECT_FALSE(file_util::PathExists(lso_path)); |
2788 | 2787 |
2789 // Check if the indexed db has disappeared too. | 2788 // Check if the indexed db has disappeared too. |
2790 EXPECT_FALSE(file_util::PathExists(idb_path)); | 2789 EXPECT_FALSE(file_util::DirectoryExists(idb_path)); |
2791 } | 2790 } |
2792 | 2791 |
2793 // Tests loading single extensions (like --load-extension) | 2792 // Tests loading single extensions (like --load-extension) |
2794 TEST_F(ExtensionServiceTest, LoadExtension) { | 2793 TEST_F(ExtensionServiceTest, LoadExtension) { |
2795 InitializeEmptyExtensionService(); | 2794 InitializeEmptyExtensionService(); |
2796 | 2795 |
2797 FilePath ext1 = data_dir_ | 2796 FilePath ext1 = data_dir_ |
2798 .AppendASCII("good") | 2797 .AppendASCII("good") |
2799 .AppendASCII("Extensions") | 2798 .AppendASCII("Extensions") |
2800 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") | 2799 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") |
(...skipping 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3966 ASSERT_FALSE(AddPendingSyncInstall()); | 3965 ASSERT_FALSE(AddPendingSyncInstall()); |
3967 | 3966 |
3968 // Wait for the external source to install. | 3967 // Wait for the external source to install. |
3969 WaitForCrxInstall(crx_path_, true); | 3968 WaitForCrxInstall(crx_path_, true); |
3970 ASSERT_TRUE(IsCrxInstalled()); | 3969 ASSERT_TRUE(IsCrxInstalled()); |
3971 | 3970 |
3972 // Now that the extension is installed, sync request should fail | 3971 // Now that the extension is installed, sync request should fail |
3973 // because the extension is already installed. | 3972 // because the extension is already installed. |
3974 ASSERT_FALSE(AddPendingSyncInstall()); | 3973 ASSERT_FALSE(AddPendingSyncInstall()); |
3975 } | 3974 } |
OLD | NEW |