summaryrefslogtreecommitdiffstats
path: root/base/path_service_unittest.cc
diff options
context:
space:
mode:
authormaruel@google.com <maruel@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-07 20:23:09 +0000
committermaruel@google.com <maruel@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-07 20:23:09 +0000
commit09ad1e629a88f99d2e93797304f4a6060915e228 (patch)
treee69ebeea9d6aa79cf134bc892e3b0573abe10c86 /base/path_service_unittest.cc
parente82b706db2d3da13746b66fd5ab7d5dd38fab17e (diff)
downloadchromium_src-09ad1e629a88f99d2e93797304f4a6060915e228.zip
chromium_src-09ad1e629a88f99d2e93797304f4a6060915e228.tar.gz
chromium_src-09ad1e629a88f99d2e93797304f4a6060915e228.tar.bz2
Improve PathServiceTest test by verifying that the returned path exists.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@533 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/path_service_unittest.cc')
-rw-r--r--base/path_service_unittest.cc31
1 files changed, 26 insertions, 5 deletions
diff --git a/base/path_service_unittest.cc b/base/path_service_unittest.cc
index a63495d..2835d37 100644
--- a/base/path_service_unittest.cc
+++ b/base/path_service_unittest.cc
@@ -31,21 +31,29 @@
#include "base/file_util.h"
#include "base/logging.h"
#include "base/path_service.h"
+#include "base/win_util.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "testing/gtest/include/gtest/gtest-spi.h"
namespace {
- class PathServiceTest : public testing::Test {
- };
-};
// Returns true if PathService::Get returns true and sets the path parameter
// to non-empty for the given PathService::DirType enumeration value.
bool ReturnsValidPath(int dir_type) {
std::wstring path;
bool result = PathService::Get(dir_type, &path);
- return result && !path.empty();
+ return result && !path.empty() && file_util::PathExists(path);
}
+// Function to test DIR_LOCAL_APP_DATA_LOW on Windows XP. Make sure it fails.
+void GetPath() {
+ std::wstring path;
+ bool result = PathService::Get(base::DIR_LOCAL_APP_DATA_LOW, &path);
+ EXPECT_FALSE(result);
+}
+
+} // namespace
+
// Test that all PathService::Get calls return a value and a true result
// in the development environment. (This test was created because a few
// later changes to Get broke the semantics of the function and yielded the
@@ -56,7 +64,20 @@ TEST(PathServiceTest, Get) {
}
#ifdef OS_WIN
for (int key = base::PATH_WIN_START + 1; key < base::PATH_WIN_END; ++key) {
- EXPECT_PRED1(ReturnsValidPath, key);
+ if (key == base::DIR_LOCAL_APP_DATA_LOW &&
+ win_util::GetWinVersion() < win_util::WINVERSION_VISTA) {
+ // DIR_LOCAL_APP_DATA_LOW is not supported prior Vista and is expected to
+ // fail.
+#ifdef _DEBUG
+ EXPECT_FATAL_FAILURE(GetPath(), ":FATAL:base_paths_win.cc(");
+#else
+ // In release, the DCHECK won't be hit. Still verify that
+ // PathService::Get() returns false.
+ GetPath();
+#endif
+ } else {
+ EXPECT_PRED1(ReturnsValidPath, key);
+ }
}
#endif
}