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/files/scoped_temp_dir.h" |
6 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
7 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
8 #include "base/path_service.h" | 9 #include "base/path_service.h" |
9 #include "base/scoped_temp_dir.h" | |
10 #include "base/scoped_temp_dir.h" | |
11 #include "base/string_util.h" | 10 #include "base/string_util.h" |
12 #include "base/values.h" | 11 #include "base/values.h" |
13 #include "chrome/browser/extensions/sandboxed_unpacker.h" | 12 #include "chrome/browser/extensions/sandboxed_unpacker.h" |
14 #include "chrome/common/chrome_paths.h" | 13 #include "chrome/common/chrome_paths.h" |
15 #include "chrome/common/extensions/extension.h" | 14 #include "chrome/common/extensions/extension.h" |
16 #include "chrome/common/extensions/extension_manifest_constants.h" | 15 #include "chrome/common/extensions/extension_manifest_constants.h" |
17 #include "chrome/common/extensions/unpacker.h" | 16 #include "chrome/common/extensions/unpacker.h" |
18 #include "content/public/test/test_browser_thread.h" | 17 #include "content/public/test/test_browser_thread.h" |
19 #include "testing/gmock/include/gmock/gmock.h" | 18 #include "testing/gmock/include/gmock/gmock.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 while (!item_in_temp.value().empty()) { | 150 while (!item_in_temp.value().empty()) { |
152 items_not_removed++; | 151 items_not_removed++; |
153 EXPECT_STREQ(FILE_PATH_LITERAL(""), item_in_temp.value().c_str()) | 152 EXPECT_STREQ(FILE_PATH_LITERAL(""), item_in_temp.value().c_str()) |
154 << "File was not removed on success."; | 153 << "File was not removed on success."; |
155 item_in_temp = temp_iterator.Next(); | 154 item_in_temp = temp_iterator.Next(); |
156 } | 155 } |
157 return (items_not_removed == 0); | 156 return (items_not_removed == 0); |
158 } | 157 } |
159 | 158 |
160 protected: | 159 protected: |
161 ScopedTempDir temp_dir_; | 160 base::ScopedTempDir temp_dir_; |
162 ScopedTempDir extensions_dir_; | 161 base::ScopedTempDir extensions_dir_; |
163 FilePath temp_path_; | 162 FilePath temp_path_; |
164 MockSandboxedUnpackerClient* client_; | 163 MockSandboxedUnpackerClient* client_; |
165 scoped_ptr<Unpacker> unpacker_; | 164 scoped_ptr<Unpacker> unpacker_; |
166 scoped_refptr<SandboxedUnpacker> sandboxed_unpacker_; | 165 scoped_refptr<SandboxedUnpacker> sandboxed_unpacker_; |
167 MessageLoop loop_; | 166 MessageLoop loop_; |
168 scoped_ptr<content::TestBrowserThread> file_thread_; | 167 scoped_ptr<content::TestBrowserThread> file_thread_; |
169 }; | 168 }; |
170 | 169 |
171 TEST_F(SandboxedUnpackerTest, NoCatalogsSuccess) { | 170 TEST_F(SandboxedUnpackerTest, NoCatalogsSuccess) { |
172 EXPECT_CALL(*client_, OnUnpackSuccess(_, _, _, _)); | 171 EXPECT_CALL(*client_, OnUnpackSuccess(_, _, _, _)); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 // Check that there is newer _locales/en_US/messages.json file. | 216 // Check that there is newer _locales/en_US/messages.json file. |
218 base::PlatformFileInfo new_info; | 217 base::PlatformFileInfo new_info; |
219 EXPECT_TRUE(file_util::GetFileInfo(messages_file, &new_info)); | 218 EXPECT_TRUE(file_util::GetFileInfo(messages_file, &new_info)); |
220 | 219 |
221 EXPECT_TRUE(new_info.last_modified > old_info.last_modified); | 220 EXPECT_TRUE(new_info.last_modified > old_info.last_modified); |
222 | 221 |
223 ASSERT_TRUE(TempFilesRemoved()); | 222 ASSERT_TRUE(TempFilesRemoved()); |
224 } | 223 } |
225 | 224 |
226 } // namespace extensions | 225 } // namespace extensions |
OLD | NEW |