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

Side by Side Diff: chrome/browser/safe_browsing/sandboxed_zip_analyzer_unittest.cc

Issue 2112543002: Convert UtilityProcessHost to bootstrap Mojo Channel using the Shell connection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@p9x
Patch Set: . Created 4 years, 5 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/safe_browsing/sandboxed_zip_analyzer.h" 5 #include "chrome/browser/safe_browsing/sandboxed_zip_analyzer.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "base/run_loop.h" 14 #include "base/run_loop.h"
15 #include "build/build_config.h" 15 #include "build/build_config.h"
16 #include "chrome/common/chrome_paths.h" 16 #include "chrome/common/chrome_paths.h"
17 #include "chrome/common/safe_browsing/zip_analyzer_results.h" 17 #include "chrome/common/safe_browsing/zip_analyzer_results.h"
18 #include "content/public/browser/shell_context.h"
18 #include "content/public/test/test_browser_thread_bundle.h" 19 #include "content/public/test/test_browser_thread_bundle.h"
19 #include "content/public/test/test_utils.h" 20 #include "content/public/test/test_utils.h"
20 #include "crypto/sha2.h" 21 #include "crypto/sha2.h"
21 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
22 23
23 namespace safe_browsing { 24 namespace safe_browsing {
24 25
25 class SandboxedZipAnalyzerTest : public ::testing::Test { 26 class SandboxedZipAnalyzerTest : public ::testing::Test {
26 protected: 27 protected:
27 // Constants for validating the data reported by the analyzer. 28 // Constants for validating the data reported by the analyzer.
(...skipping 27 matching lines...) Expand all
55 *results_ = results; 56 *results_ = results;
56 quit_closure_.Run(); 57 quit_closure_.Run();
57 } 58 }
58 59
59 base::Closure quit_closure_; 60 base::Closure quit_closure_;
60 zip_analyzer::Results* results_; 61 zip_analyzer::Results* results_;
61 DISALLOW_COPY_AND_ASSIGN(ResultsGetter); 62 DISALLOW_COPY_AND_ASSIGN(ResultsGetter);
62 }; 63 };
63 64
64 SandboxedZipAnalyzerTest() 65 SandboxedZipAnalyzerTest()
65 : browser_thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) {} 66 : browser_thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) {
67 shell_context_ = content::ShellContext::Create();
68 }
66 69
67 void SetUp() override { 70 void SetUp() override {
68 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &dir_test_data_)); 71 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &dir_test_data_));
69 dir_test_data_ = dir_test_data_.AppendASCII("safe_browsing"); 72 dir_test_data_ = dir_test_data_.AppendASCII("safe_browsing");
70 dir_test_data_ = dir_test_data_.AppendASCII("download_protection"); 73 dir_test_data_ = dir_test_data_.AppendASCII("download_protection");
71 } 74 }
72 75
73 // Runs a sandboxed zip analyzer on |file_path|, writing its results into 76 // Runs a sandboxed zip analyzer on |file_path|, writing its results into
74 // |results|. 77 // |results|.
75 void RunAnalyzer(const base::FilePath& file_path, 78 void RunAnalyzer(const base::FilePath& file_path,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 static const uint8_t kUnsignedDigest[]; 134 static const uint8_t kUnsignedDigest[];
132 static const uint8_t kSignedDigest[]; 135 static const uint8_t kSignedDigest[];
133 static const uint8_t kJSEFileDigest[]; 136 static const uint8_t kJSEFileDigest[];
134 static const BinaryData kUnsignedExe; 137 static const BinaryData kUnsignedExe;
135 static const BinaryData kSignedExe; 138 static const BinaryData kSignedExe;
136 static const BinaryData kJSEFile; 139 static const BinaryData kJSEFile;
137 140
138 base::FilePath dir_test_data_; 141 base::FilePath dir_test_data_;
139 content::TestBrowserThreadBundle browser_thread_bundle_; 142 content::TestBrowserThreadBundle browser_thread_bundle_;
140 content::InProcessUtilityThreadHelper utility_thread_helper_; 143 content::InProcessUtilityThreadHelper utility_thread_helper_;
144 std::unique_ptr<content::ShellContext> shell_context_;
141 }; 145 };
142 146
143 // static 147 // static
144 const uint8_t SandboxedZipAnalyzerTest::kUnsignedDigest[] = { 148 const uint8_t SandboxedZipAnalyzerTest::kUnsignedDigest[] = {
145 0x1e, 0x95, 0x4d, 0x9c, 0xe0, 0x38, 0x9e, 0x2b, 0xa7, 0x44, 0x72, 149 0x1e, 0x95, 0x4d, 0x9c, 0xe0, 0x38, 0x9e, 0x2b, 0xa7, 0x44, 0x72,
146 0x16, 0xf2, 0x17, 0x61, 0xf9, 0x8d, 0x1e, 0x65, 0x40, 0xc2, 0xab, 150 0x16, 0xf2, 0x17, 0x61, 0xf9, 0x8d, 0x1e, 0x65, 0x40, 0xc2, 0xab,
147 0xec, 0xdb, 0xec, 0xff, 0x57, 0x0e, 0x36, 0xc4, 0x93, 0xdb}; 151 0xec, 0xdb, 0xec, 0xff, 0x57, 0x0e, 0x36, 0xc4, 0x93, 0xdb};
148 const uint8_t SandboxedZipAnalyzerTest::kSignedDigest[] = { 152 const uint8_t SandboxedZipAnalyzerTest::kSignedDigest[] = {
149 0xe1, 0x1f, 0xfa, 0x0c, 0x9f, 0x25, 0x23, 0x44, 0x53, 0xa9, 0xed, 153 0xe1, 0x1f, 0xfa, 0x0c, 0x9f, 0x25, 0x23, 0x44, 0x53, 0xa9, 0xed,
150 0xd1, 0xcb, 0x25, 0x1d, 0x46, 0x10, 0x7f, 0x34, 0xb5, 0x36, 0xad, 154 0xd1, 0xcb, 0x25, 0x1d, 0x46, 0x10, 0x7f, 0x34, 0xb5, 0x36, 0xad,
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 RunAnalyzer(dir_test_data_.AppendASCII("zipfile_one_jse_file.zip"), &results); 281 RunAnalyzer(dir_test_data_.AppendASCII("zipfile_one_jse_file.zip"), &results);
278 ASSERT_TRUE(results.success); 282 ASSERT_TRUE(results.success);
279 EXPECT_TRUE(results.has_executable); 283 EXPECT_TRUE(results.has_executable);
280 EXPECT_FALSE(results.has_archive); 284 EXPECT_FALSE(results.has_archive);
281 ASSERT_EQ(1, results.archived_binary.size()); 285 ASSERT_EQ(1, results.archived_binary.size());
282 ExpectBinary(kJSEFile, results.archived_binary.Get(0)); 286 ExpectBinary(kJSEFile, results.archived_binary.Get(0));
283 EXPECT_TRUE(results.archived_archive_filenames.empty()); 287 EXPECT_TRUE(results.archived_archive_filenames.empty());
284 } 288 }
285 289
286 } // namespace safe_browsing 290 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/sandboxed_dmg_analyzer_mac_unittest.cc ('k') | content/browser/browser_main_loop.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698