| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/scoped_temp_dir.h" | 9 #include "base/scoped_temp_dir.h" |
| 10 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 const DictionaryValue* original_manifest, | 34 const DictionaryValue* original_manifest, |
| 35 const Extension* extension) { | 35 const Extension* extension) { |
| 36 // Don't delete temp_dir here, we need to do some post op checking. | 36 // Don't delete temp_dir here, we need to do some post op checking. |
| 37 } | 37 } |
| 38 | 38 |
| 39 } // namespace | 39 } // namespace |
| 40 | 40 |
| 41 class MockSandboxedExtensionUnpackerClient | 41 class MockSandboxedExtensionUnpackerClient |
| 42 : public SandboxedExtensionUnpackerClient { | 42 : public SandboxedExtensionUnpackerClient { |
| 43 public: | 43 public: |
| 44 virtual ~MockSandboxedExtensionUnpackerClient() {} | |
| 45 | |
| 46 MOCK_METHOD4(OnUnpackSuccess, | 44 MOCK_METHOD4(OnUnpackSuccess, |
| 47 void(const FilePath& temp_dir, | 45 void(const FilePath& temp_dir, |
| 48 const FilePath& extension_root, | 46 const FilePath& extension_root, |
| 49 const DictionaryValue* original_manifest, | 47 const DictionaryValue* original_manifest, |
| 50 const Extension* extension)); | 48 const Extension* extension)); |
| 51 | 49 |
| 52 MOCK_METHOD1(OnUnpackFailure, | 50 MOCK_METHOD1(OnUnpackFailure, |
| 53 void(const string16& error)); | 51 void(const string16& error)); |
| 54 | 52 |
| 55 void DelegateToFake() { | 53 void DelegateToFake() { |
| 56 ON_CALL(*this, OnUnpackSuccess(_, _, _, _)) | 54 ON_CALL(*this, OnUnpackSuccess(_, _, _, _)) |
| 57 .WillByDefault(Invoke(::OnUnpackSuccess)); | 55 .WillByDefault(Invoke(::OnUnpackSuccess)); |
| 58 } | 56 } |
| 57 |
| 58 protected: |
| 59 virtual ~MockSandboxedExtensionUnpackerClient() {} |
| 59 }; | 60 }; |
| 60 | 61 |
| 61 class SandboxedExtensionUnpackerTest : public testing::Test { | 62 class SandboxedExtensionUnpackerTest : public testing::Test { |
| 62 public: | 63 public: |
| 63 virtual void SetUp() { | 64 virtual void SetUp() { |
| 64 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 65 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 65 file_thread_.reset(new content::TestBrowserThread(BrowserThread::FILE, | 66 file_thread_.reset(new content::TestBrowserThread(BrowserThread::FILE, |
| 66 &loop_)); | 67 &loop_)); |
| 67 // It will delete itself. | 68 // It will delete itself. |
| 68 client_ = new MockSandboxedExtensionUnpackerClient; | 69 client_ = new MockSandboxedExtensionUnpackerClient; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 OnUnpackSucceeded(); | 213 OnUnpackSucceeded(); |
| 213 | 214 |
| 214 // Check that there is newer _locales/en_US/messages.json file. | 215 // Check that there is newer _locales/en_US/messages.json file. |
| 215 base::PlatformFileInfo new_info; | 216 base::PlatformFileInfo new_info; |
| 216 EXPECT_TRUE(file_util::GetFileInfo(messages_file, &new_info)); | 217 EXPECT_TRUE(file_util::GetFileInfo(messages_file, &new_info)); |
| 217 | 218 |
| 218 EXPECT_TRUE(new_info.last_modified > old_info.last_modified); | 219 EXPECT_TRUE(new_info.last_modified > old_info.last_modified); |
| 219 | 220 |
| 220 ASSERT_TRUE(TempFilesRemoved()); | 221 ASSERT_TRUE(TempFilesRemoved()); |
| 221 } | 222 } |
| OLD | NEW |