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

Side by Side Diff: chrome/browser/safe_browsing/sandboxed_dmg_analyzer_mac_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_dmg_analyzer_mac.h" 5 #include "chrome/browser/safe_browsing/sandboxed_dmg_analyzer_mac.h"
6 6
7 #include <mach-o/loader.h> 7 #include <mach-o/loader.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.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 "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.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 "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
21 22
22 namespace safe_browsing { 23 namespace safe_browsing {
23 namespace { 24 namespace {
24 25
25 class SandboxedDMGAnalyzerTest : public testing::Test { 26 class SandboxedDMGAnalyzerTest : public testing::Test {
26 public: 27 public:
27 SandboxedDMGAnalyzerTest() 28 SandboxedDMGAnalyzerTest()
28 : browser_thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) { 29 : browser_thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) {
29 } 30 }
30 31
32 void SetUp() override {
33 shell_context_ = content::ShellContext::Create();
34 }
35
31 void AnalyzeFile(const base::FilePath& path, 36 void AnalyzeFile(const base::FilePath& path,
32 zip_analyzer::Results* results) { 37 zip_analyzer::Results* results) {
33 base::RunLoop run_loop; 38 base::RunLoop run_loop;
34 ResultsGetter results_getter(run_loop.QuitClosure(), results); 39 ResultsGetter results_getter(run_loop.QuitClosure(), results);
35 scoped_refptr<SandboxedDMGAnalyzer> analyzer( 40 scoped_refptr<SandboxedDMGAnalyzer> analyzer(
36 new SandboxedDMGAnalyzer(path, results_getter.GetCallback())); 41 new SandboxedDMGAnalyzer(path, results_getter.GetCallback()));
37 analyzer->Start(); 42 analyzer->Start();
38 run_loop.Run(); 43 run_loop.Run();
39 } 44 }
40 45
(...skipping 26 matching lines...) Expand all
67 } 72 }
68 73
69 base::Closure next_closure_; 74 base::Closure next_closure_;
70 zip_analyzer::Results* results_; 75 zip_analyzer::Results* results_;
71 76
72 DISALLOW_COPY_AND_ASSIGN(ResultsGetter); 77 DISALLOW_COPY_AND_ASSIGN(ResultsGetter);
73 }; 78 };
74 79
75 content::TestBrowserThreadBundle browser_thread_bundle_; 80 content::TestBrowserThreadBundle browser_thread_bundle_;
76 content::InProcessUtilityThreadHelper utility_thread_helper_; 81 content::InProcessUtilityThreadHelper utility_thread_helper_;
82 std::unique_ptr<content::ShellContext> shell_context_;
77 }; 83 };
78 84
79 TEST_F(SandboxedDMGAnalyzerTest, AnalyzeDMG) { 85 TEST_F(SandboxedDMGAnalyzerTest, AnalyzeDMG) {
80 base::FilePath path; 86 base::FilePath path;
81 ASSERT_NO_FATAL_FAILURE(path = GetFilePath("mach_o_in_dmg.dmg")); 87 ASSERT_NO_FATAL_FAILURE(path = GetFilePath("mach_o_in_dmg.dmg"));
82 88
83 zip_analyzer::Results results; 89 zip_analyzer::Results results;
84 AnalyzeFile(path, &results); 90 AnalyzeFile(path, &results);
85 91
86 EXPECT_TRUE(results.success); 92 EXPECT_TRUE(results.success);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 ADD_FAILURE() << "Unepxected result file " << binary.file_basename(); 142 ADD_FAILURE() << "Unepxected result file " << binary.file_basename();
137 } 143 }
138 } 144 }
139 145
140 EXPECT_TRUE(got_executable); 146 EXPECT_TRUE(got_executable);
141 EXPECT_TRUE(got_dylib); 147 EXPECT_TRUE(got_dylib);
142 } 148 }
143 149
144 } // namespace 150 } // namespace
145 } // namespace safe_browsing 151 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698