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

Unified Diff: chrome/test/base/ui_test_utils.cc

Issue 10837207: Add NaCl smoke test to browser_tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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: chrome/test/base/ui_test_utils.cc
diff --git a/chrome/test/base/ui_test_utils.cc b/chrome/test/base/ui_test_utils.cc
index faae2365366f561d65f03a70debe1a40628fa820..2df298020c59997e068cfd520d018761689b1ed6 100644
--- a/chrome/test/base/ui_test_utils.cc
+++ b/chrome/test/base/ui_test_utils.cc
@@ -15,6 +15,7 @@
#include "base/callback.h"
#include "base/command_line.h"
#include "base/file_path.h"
+#include "base/file_util.h"
#include "base/json/json_reader.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop.h"
@@ -315,6 +316,48 @@ GURL GetTestUrl(const FilePath& dir, const FilePath& file) {
return net::FilePathToFileURL(GetTestFilePath(dir, file));
}
+bool GetRelativeBuildDirectory(FilePath* build_dir) {
+ // This function is used to find the build directory so TestServer can serve
+ // built files (nexes, etc). TestServer expects a path relative to the source
+ // root.
+ FilePath exe_dir = CommandLine::ForCurrentProcess()->GetProgram().DirName();
+ FilePath src_dir;
+ if (!PathService::Get(base::DIR_SOURCE_ROOT, &src_dir))
+ return false;
+
+ // We must first generate absolute paths to SRC and EXE and from there
+ // generate a relative path.
+ if (!exe_dir.IsAbsolute()) file_util::AbsolutePath(&exe_dir);
sky 2012/08/10 22:34:15 no single line if statements.
Nick Bray 2012/08/10 23:16:28 Done.
+ if (!src_dir.IsAbsolute()) file_util::AbsolutePath(&src_dir);
+ if (!exe_dir.IsAbsolute())
+ return false;
+ if (!src_dir.IsAbsolute())
+ return false;
+
+ size_t match, exe_size, src_size;
+ std::vector<FilePath::StringType> src_parts, exe_parts;
+
+ // Determine point at which src and exe diverge.
+ exe_dir.GetComponents(&exe_parts);
+ src_dir.GetComponents(&src_parts);
+ exe_size = exe_parts.size();
+ src_size = src_parts.size();
+ for (match = 0; match < exe_size && match < src_size; ++match) {
+ if (exe_parts[match] != src_parts[match])
+ break;
+ }
+
+ // Create a relative path.
+ *build_dir = FilePath();
+ for (size_t tmp_itr = match; tmp_itr < src_size; ++tmp_itr) {
sky 2012/08/10 22:34:15 no {} here and 355.
Nick Bray 2012/08/10 23:16:28 Done.
+ *build_dir = build_dir->Append(FILE_PATH_LITERAL(".."));
+ }
+ for (; match < exe_size; ++match) {
+ *build_dir = build_dir->Append(exe_parts[match]);
+ }
+ return true;
+}
+
AppModalDialog* WaitForAppModalDialog() {
content::WindowedNotificationObserver observer(
chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN,

Powered by Google App Engine
This is Rietveld 408576698