Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: installer/src/installer-lib/test/process_test.cpp

Issue 29329510: Issue #1186 - Style conformity for names in installer tests (Closed)
Patch Set: Created Nov. 14, 2015, 5:55 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: installer/src/installer-lib/test/process_test.cpp
===================================================================
--- a/installer/src/installer-lib/test/process_test.cpp
+++ b/installer/src/installer-lib/test/process_test.cpp
@@ -9,37 +9,37 @@
// Comparison objects
//-------------------------------------------------------
-const wchar_t exact_exe_name[] = L"installer-ca-tests.exe";
-const std::wstring exact_exe_string(exact_exe_name);
-const WstringCaseInsensitive exact_exe_string_ci(exact_exe_name);
+const wchar_t exactExeName[] = L"installer-ca-tests.exe";
+const std::wstring exactExeString(exactExeName);
+const WstringCaseInsensitive exactExeStringCi(exactExeName);
-const wchar_t mixedcase_exe_name[] = L"Installer-CA-Tests.exe";
-const WstringCaseInsensitive mixedcase_exe_string_ci(mixedcase_exe_name);
+const wchar_t mixedcaseExeName[] = L"Installer-CA-Tests.exe";
+const WstringCaseInsensitive mixedcaseExeStringCi(mixedcaseExeName);
-const wchar_t unknown_name[] = L"non-matching-name";
-const wchar_t* multiple_exe_names[] = { mixedcase_exe_name, unknown_name };
+const wchar_t unknownName[] = L"non-matching-name";
+const wchar_t* multipleExeNames[] = {mixedcaseExeName, unknownName};
/**
* Compare to our own process name, case-sensitive, no length limit
*/
-struct our_process_by_name
+struct OurProcessByName
: std::unary_function<PROCESSENTRY32W, bool>
{
bool operator()(const PROCESSENTRY32W& process)
{
- return std::wstring(process.szExeFile) == exact_exe_string;
+ return std::wstring(process.szExeFile) == exactExeString;
};
};
/**
* Compare to our own process name, case-insensitive, no length limit
*/
-struct our_process_by_name_CI
+struct OurProcessByNameCi
: std::unary_function<PROCESSENTRY32W, bool>
{
bool operator()(const PROCESSENTRY32W& process)
{
- return WstringCaseInsensitive(process.szExeFile) == mixedcase_exe_string_ci;
+ return WstringCaseInsensitive(process.szExeFile) == mixedcaseExeStringCi;
};
};
@@ -48,7 +48,7 @@
/**
* Filter by process name. Comparison is case-insensitive.
*/
-class process_by_any_file_name_CI
+class ProcessByAnyFileNameCi
: public std::unary_function<PROCESSENTRY32W, bool>
{
const FileNameSet& names;
@@ -57,7 +57,7 @@
{
return names.find(process.szExeFile) != names.end();
}
- process_by_any_file_name_CI(const FileNameSet& names)
+ ProcessByAnyFileNameCi(const FileNameSet& names)
: names(names)
{}
};
@@ -65,7 +65,7 @@
/**
* Filter by process name. Comparison is case-insensitive.
*/
-class process_by_name_CI
+class ProcessByNameCi
: public std::unary_function<PROCESSENTRY32W, bool>
{
const WstringCaseInsensitive _name;
@@ -75,7 +75,7 @@
return _name == WstringCaseInsensitive(process.szExeFile);
}
- process_by_name_CI(const wchar_t* name)
+ ProcessByNameCi(const wchar_t* name)
: _name(name)
{}
};
@@ -83,100 +83,100 @@
//-------------------------------------------------------
// TESTS, no snapshots
//-------------------------------------------------------
-PROCESSENTRY32 process_with_name(const wchar_t* s)
+PROCESSENTRY32 ProcessWithName(const wchar_t* s)
{
PROCESSENTRY32W p;
wcsncpy(p.szExeFile, s, MAX_PATH);
return p;
}
-PROCESSENTRY32 process_empty = process_with_name(L"");
-PROCESSENTRY32 process_exact = process_with_name(exact_exe_name);
-PROCESSENTRY32 process_mixedcase = process_with_name(mixedcase_exe_name);
-PROCESSENTRY32 process_explorer = process_with_name(L"explorer.exe");
-PROCESSENTRY32 process_absent = process_with_name(L"no_such_name");
+PROCESSENTRY32 processEmpty = ProcessWithName(L"");
+PROCESSENTRY32 processExact = ProcessWithName(exactExeName);
+PROCESSENTRY32 processMixedcase = ProcessWithName(mixedcaseExeName);
+PROCESSENTRY32 processExplorer = ProcessWithName(L"explorer.exe");
+PROCESSENTRY32 processAbsent = ProcessWithName(L"no_such_name");
-FileNameSet multiple_name_set(multiple_exe_names);
-process_by_any_file_name_CI find_in_set(multiple_name_set);
-ProcessByAnyExeNotImmersive find_in_set_not_immersive(multiple_name_set);
+FileNameSet multipleNameSet(multipleExeNames);
+ProcessByAnyFileNameCi findInSet(multipleNameSet);
+ProcessByAnyExeNotImmersive findInSetNotImmersive(multipleNameSet);
-TEST(file_name_set, validate_setup)
+TEST(FileNameSet, ValidateSetup)
{
- ASSERT_EQ(2u, multiple_name_set.size());
- ASSERT_TRUE(multiple_name_set.find(exact_exe_string_ci) != multiple_name_set.end());
- ASSERT_TRUE(multiple_name_set.find(mixedcase_exe_string_ci) != multiple_name_set.end());
- ASSERT_TRUE(multiple_name_set.find(L"") == multiple_name_set.end());
- ASSERT_TRUE(multiple_name_set.find(L"not-in-list") == multiple_name_set.end());
+ ASSERT_EQ(2u, multipleNameSet.size());
+ ASSERT_TRUE(multipleNameSet.find(exactExeStringCi) != multipleNameSet.end());
+ ASSERT_TRUE(multipleNameSet.find(mixedcaseExeStringCi) != multipleNameSet.end());
+ ASSERT_TRUE(multipleNameSet.find(L"") == multipleNameSet.end());
+ ASSERT_TRUE(multipleNameSet.find(L"not-in-list") == multipleNameSet.end());
}
-TEST(process_by_any_file_name_CI, empty)
+TEST(ProcessByAnyFileNameCi, Empty)
{
FileNameSet s;
- process_by_any_file_name_CI x(s);
+ ProcessByAnyFileNameCi x(s);
- ASSERT_FALSE(x(process_empty));
- ASSERT_FALSE(x(process_exact));
- ASSERT_FALSE(x(process_mixedcase));
- ASSERT_FALSE(x(process_explorer));
- ASSERT_FALSE(x(process_absent));
+ ASSERT_FALSE(x(processEmpty));
+ ASSERT_FALSE(x(processExact));
+ ASSERT_FALSE(x(processMixedcase));
+ ASSERT_FALSE(x(processExplorer));
+ ASSERT_FALSE(x(processAbsent));
}
-TEST(process_by_any_file_name_CI, single_element_known)
+TEST(ProcessByAnyFileNameCi, SingleElementKnown)
{
- const wchar_t* elements[1] = { exact_exe_name };
+ const wchar_t* elements[1] = {exactExeName};
FileNameSet s(elements);
- process_by_any_file_name_CI x(s);
+ ProcessByAnyFileNameCi x(s);
- ASSERT_FALSE(x(process_empty));
- ASSERT_TRUE(x(process_exact));
- ASSERT_TRUE(x(process_mixedcase));
- ASSERT_FALSE(x(process_explorer));
- ASSERT_FALSE(x(process_absent));
+ ASSERT_FALSE(x(processEmpty));
+ ASSERT_TRUE(x(processExact));
+ ASSERT_TRUE(x(processMixedcase));
+ ASSERT_FALSE(x(processExplorer));
+ ASSERT_FALSE(x(processAbsent));
}
-TEST(process_by_any_file_name_CI, single_element_unknown)
+TEST(ProcessByAnyFileNameCi, SingleElementUnknown)
{
- const wchar_t* elements[1] = { unknown_name };
+ const wchar_t* elements[1] = {unknownName};
FileNameSet s(elements);
- process_by_any_file_name_CI x(s);
+ ProcessByAnyFileNameCi x(s);
- ASSERT_FALSE(x(process_empty));
- ASSERT_FALSE(x(process_exact));
- ASSERT_FALSE(x(process_mixedcase));
- ASSERT_FALSE(x(process_explorer));
- ASSERT_FALSE(x(process_absent));
+ ASSERT_FALSE(x(processEmpty));
+ ASSERT_FALSE(x(processExact));
+ ASSERT_FALSE(x(processMixedcase));
+ ASSERT_FALSE(x(processExplorer));
+ ASSERT_FALSE(x(processAbsent));
}
-TEST(process_by_any_file_name_CI, two_elements)
+TEST(ProcessByAnyFileNameCi, TwoElements)
{
- FileNameSet s(multiple_exe_names);
- process_by_any_file_name_CI x(s);
+ FileNameSet s(multipleExeNames);
+ ProcessByAnyFileNameCi x(s);
- ASSERT_FALSE(find_in_set(process_empty));
- ASSERT_TRUE(find_in_set(process_exact));
- ASSERT_TRUE(find_in_set(process_mixedcase));
- ASSERT_FALSE(find_in_set(process_explorer));
- ASSERT_FALSE(find_in_set(process_absent));
+ ASSERT_FALSE(findInSet(processEmpty));
+ ASSERT_TRUE(findInSet(processExact));
+ ASSERT_TRUE(findInSet(processMixedcase));
+ ASSERT_FALSE(findInSet(processExplorer));
+ ASSERT_FALSE(findInSet(processAbsent));
}
//-------------------------------------------------------
// Single-snapshot version of initializers
//-------------------------------------------------------
/**
- * Single-snapshot version of initialize_process_list, for testing.
+ * Single-snapshot version of InitializeProcessList, for testing.
*/
template<class T, class Admittance, class Extractor>
-void initialize_process_list(std::vector<T>& v, Admittance admit = Admittance(), Extractor extract = Extractor())
+void InitializeProcessList(std::vector<T>& v, Admittance admit = Admittance(), Extractor extract = Extractor())
{
InitializeProcessList(v, ProcessSnapshot(), admit, extract);
}
/**
- * Single-snapshot version of initialize_process_set, for testing.
+ * Single-snapshot version of InitializeProcessSet, for testing.
*/
template<class T, class Admittance, class Extractor>
-void initialize_process_set(std::set<T>& s, Admittance admit = Admittance(), Extractor extract = Extractor())
+void InitializeProcessSet(std::set<T>& s, Admittance admit = Admittance(), Extractor extract = Extractor())
{
InitializeProcessSet(s, ProcessSnapshot(), admit, extract);
}
@@ -187,20 +187,20 @@
/**
* Construction test ensures that we don't throw and that at least one process shows up.
*/
-TEST(Process_List_Test, construct_vector)
+TEST(ProcessListTest, ConstructVector)
{
std::vector<PROCESSENTRY32W> v;
- initialize_process_list(v, EveryProcess(), CopyAll());
+ InitializeProcessList(v, EveryProcess(), CopyAll());
ASSERT_GE(v.size(), 1u);
}
/**
* The only process we are really guaranteed to have is this test process itself.
*/
-TEST(Process_List_Test, find_our_process)
+TEST(ProcessListTest, FindOurProcess)
{
std::vector<PROCESSENTRY32W> v;
- initialize_process_list(v, our_process_by_name(), CopyAll());
+ InitializeProcessList(v, OurProcessByName(), CopyAll());
size_t size(v.size());
EXPECT_EQ(1u, size); // Please, don't run multiple test executables simultaneously
ASSERT_GE(1u, size);
@@ -210,10 +210,10 @@
* The only process we are really guaranteed to have is this test process itself.
* This test uses same one used in Process_Closer
*/
-TEST(Process_List_Test, find_our_process_CI_generic)
+TEST(ProcessListTest, FindOurProcessCiGeneric)
{
std::vector<PROCESSENTRY32W> v;
- initialize_process_list(v, process_by_name_CI(mixedcase_exe_name), CopyAll());
+ InitializeProcessList(v, ProcessByNameCi(mixedcaseExeName), CopyAll());
size_t size(v.size());
EXPECT_EQ(1u, size); // Please, don't run multiple test executables simultaneously
ASSERT_GE(1u, size);
@@ -223,10 +223,10 @@
* The only process we are really guaranteed to have is this test process itself.
* This test uses the generic filter function.
*/
-TEST(Process_List_Test, find_our_process_CI_as_used)
+TEST(ProcessListTest, FindOurProcessCiAsUsed)
{
std::vector<PROCESSENTRY32W> v;
- initialize_process_list(v, process_by_any_file_name_CI(FileNameSet(multiple_exe_names)), CopyAll());
+ InitializeProcessList(v, ProcessByAnyFileNameCi(FileNameSet(multipleExeNames)), CopyAll());
size_t size(v.size());
EXPECT_EQ(1u, size); // Please, don't run multiple test executables simultaneously
ASSERT_GE(1u, size);
@@ -235,10 +235,10 @@
/**
* Locate the PID of our process.
*/
-TEST(Process_List_Test, find_our_PID)
+TEST(ProcessListTest, FindOurPid)
{
std::vector<DWORD> v;
- initialize_process_list(v, our_process_by_name(), CopyPID());
+ InitializeProcessList(v, OurProcessByName(), CopyPid());
size_t size(v.size());
EXPECT_EQ(size, 1u); // Please, don't run multiple test executables simultaneously
ASSERT_GE(size, 1u);
@@ -247,10 +247,10 @@
/**
* Locate the PID of our process using the
*/
-TEST(Process_List_Test, find_our_process_in_set)
+TEST(ProcessListTest, FindOurProcessInSet)
{
std::vector<DWORD> v;
- initialize_process_list(v, find_in_set, CopyPID());
+ InitializeProcessList(v, findInSet, CopyPid());
size_t size(v.size());
EXPECT_EQ(size, 1u); // Please, don't run multiple test executables simultaneously
ASSERT_GE(size, 1u);
@@ -261,32 +261,32 @@
//-------------------------------------------------------
/*
* Can't use copy_all without a definition for "less<PROCESSENTRY32W>".
- * Thus all tests only use copy_PID
+ * Thus all tests only use CopyPid
*/
/**
* Construction test ensures that we don't throw and that at least one process shows up.
*/
-TEST(pid_set, construct_set)
+TEST(PidSet, ConstructSet)
{
std::set<DWORD> s;
- initialize_process_set(s, EveryProcess(), CopyPID());
+ InitializeProcessSet(s, EveryProcess(), CopyPid());
ASSERT_GE(s.size(), 1u);
}
-TEST(pid_set, find_our_process_in_set)
+TEST(PidSet, FindOurProcessInSet)
{
std::set<DWORD> s;
- initialize_process_set(s, find_in_set, CopyPID());
+ InitializeProcessSet(s, findInSet, CopyPid());
size_t size(s.size());
EXPECT_EQ(size, 1u);
ASSERT_GE(size, 1u);
}
-TEST(pid_set, find_our_process_in_set_not_immersive)
+TEST(PidSet, FindOurProcessInSetNotImmersive)
{
std::set<DWORD> s;
- initialize_process_set(s, find_in_set_not_immersive, CopyPID());
+ InitializeProcessSet(s, findInSetNotImmersive, CopyPid());
size_t size(s.size());
EXPECT_EQ(size, 1u);
ASSERT_GE(size, 1u);
« no previous file with comments | « installer/src/installer-lib/test/exception_test.cpp ('k') | installer/src/installer-lib/test/property_test.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld