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

Unified Diff: base/path_service_unittest.cc

Issue 7087014: Support automatic javascript test registry in gtest when creating WebUI tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added example of helper functions which aren't included as tests. Created 9 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 side-by-side diff with in-line comments
Download patch
Index: base/path_service_unittest.cc
diff --git a/base/path_service_unittest.cc b/base/path_service_unittest.cc
index 26998de5c097ceaccf95e83f0cac54056c0a0255..7fa49a52a3a9dd3e1e73b1d644f4ab2295376574 100644
--- a/base/path_service_unittest.cc
+++ b/base/path_service_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -39,6 +39,17 @@ bool ReturnsInvalidPath(int dir_type) {
}
#endif
+const int kSimpleProviderKey = 9999;
+const FilePath::CharType kSimpleProviderPath[] = FILE_PATH_LITERAL(".");
+
+bool SimpleProvider(int key, FilePath* result) {
+ if (key == kSimpleProviderKey) {
+ *result = FilePath(kSimpleProviderPath);
+ return true;
+ }
+ return false;
+}
+
} // namespace
// On the Mac this winds up using some autoreleased objects, so we need to
@@ -70,3 +81,12 @@ TEST_F(PathServiceTest, Get) {
}
#endif
}
+
+TEST_F(PathServiceTest, RegisterUnregister) {
+ EXPECT_FALSE(ReturnsValidPath(kSimpleProviderKey)) << kSimpleProviderKey;
+ PathService::RegisterProvider(&SimpleProvider,
+ kSimpleProviderKey, kSimpleProviderKey+1);
+ EXPECT_TRUE(ReturnsValidPath(kSimpleProviderKey)) << kSimpleProviderKey;
+ PathService::UnregisterProvider(&SimpleProvider);
+ EXPECT_FALSE(ReturnsValidPath(kSimpleProviderKey)) << kSimpleProviderKey;
+}

Powered by Google App Engine
This is Rietveld 408576698