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

Side by Side Diff: components/browser_watcher/stability_debugging_win_unittest.cc

Issue 2852693003: Add stability_debugging_win_unittest.cc to build config (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « components/browser_watcher/BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/browser_watcher/stability_debugging_win.h" 5 #include "components/browser_watcher/stability_debugging.h"
6 6
7 #include "base/files/file_enumerator.h" 7 #include "base/files/file_enumerator.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
11 #include "base/process/process.h" 11 #include "base/process/process.h"
12 #include "base/test/multiprocess_test.h" 12 #include "base/test/multiprocess_test.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "testing/multiprocess_func_list.h" 14 #include "testing/multiprocess_func_list.h"
15 15
(...skipping 13 matching lines...) Expand all
29 ASSERT_TRUE(GetStabilityFileForProcess(base::Process::Current(), empty_path, 29 ASSERT_TRUE(GetStabilityFileForProcess(base::Process::Current(), empty_path,
30 &stability_path)); 30 &stability_path));
31 31
32 // Ensure requesting a second time produces the same. 32 // Ensure requesting a second time produces the same.
33 base::FilePath stability_path_two; 33 base::FilePath stability_path_two;
34 ASSERT_TRUE(GetStabilityFileForProcess(base::Process::Current(), empty_path, 34 ASSERT_TRUE(GetStabilityFileForProcess(base::Process::Current(), empty_path,
35 &stability_path_two)); 35 &stability_path_two));
36 EXPECT_EQ(stability_path, stability_path_two); 36 EXPECT_EQ(stability_path, stability_path_two);
37 37
38 // Ensure a different process has a different stability path. 38 // Ensure a different process has a different stability path.
39 base::SpawnChildResult spawn_result = SpawnChild("DummyProcess");
39 base::FilePath stability_path_other; 40 base::FilePath stability_path_other;
40 ASSERT_TRUE(GetStabilityFileForProcess(SpawnChild("DummyProcess"), empty_path, 41 ASSERT_TRUE(GetStabilityFileForProcess(spawn_result.process, empty_path,
41 &stability_path_other)); 42 &stability_path_other));
42 EXPECT_NE(stability_path, stability_path_other); 43 EXPECT_NE(stability_path, stability_path_other);
43 } 44 }
44 45
45 TEST(StabilityDebuggingWinTest, 46 TEST(StabilityDebuggingWinTest,
46 GetStabilityFilePatternMatchesGetStabilityFileForProcessResult) { 47 GetStabilityFilePatternMatchesGetStabilityFileForProcessResult) {
47 // GetStabilityFileForProcess file names must match GetStabilityFilePattern 48 // GetStabilityFileForProcess file names must match GetStabilityFilePattern
48 // according to 49 // according to
49 // FileEnumerator's algorithm. We test this by writing out some files and 50 // FileEnumerator's algorithm. We test this by writing out some files and
50 // validating what is matched. 51 // validating what is matched.
51 52
52 base::ScopedTempDir temp_dir; 53 base::ScopedTempDir temp_dir;
53 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 54 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
54 base::FilePath user_data_dir = temp_dir.path(); 55 base::FilePath user_data_dir = temp_dir.GetPath();
55 56
56 // Create the stability directory. 57 // Create the stability directory.
57 base::FilePath stability_dir = GetStabilityDir(user_data_dir); 58 base::FilePath stability_dir = GetStabilityDir(user_data_dir);
58 ASSERT_TRUE(base::CreateDirectory(stability_dir)); 59 ASSERT_TRUE(base::CreateDirectory(stability_dir));
59 60
60 // Write a stability file. 61 // Write a stability file.
61 base::FilePath stability_file; 62 base::FilePath stability_file;
62 ASSERT_TRUE(GetStabilityFileForProcess(base::Process::Current(), 63 ASSERT_TRUE(GetStabilityFileForProcess(base::Process::Current(),
63 user_data_dir, &stability_file)); 64 user_data_dir, &stability_file));
64 { 65 {
(...skipping 11 matching lines...) Expand all
76 77
77 // Validate only the stability file matches. 78 // Validate only the stability file matches.
78 base::FileEnumerator enumerator(stability_dir, false /* recursive */, 79 base::FileEnumerator enumerator(stability_dir, false /* recursive */,
79 base::FileEnumerator::FILES, 80 base::FileEnumerator::FILES,
80 GetStabilityFilePattern()); 81 GetStabilityFilePattern());
81 ASSERT_EQ(stability_file, enumerator.Next()); 82 ASSERT_EQ(stability_file, enumerator.Next());
82 ASSERT_TRUE(enumerator.Next().empty()); 83 ASSERT_TRUE(enumerator.Next().empty());
83 } 84 }
84 85
85 } // namespace browser_watcher 86 } // namespace browser_watcher
OLDNEW
« no previous file with comments | « components/browser_watcher/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698