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

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

Issue 10827357: Add NaCl smoke test to browser_tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: VS2010 fix? 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
« no previous file with comments | « chrome/test/base/ui_test_utils.h ('k') | chrome/test/data/nacl/DEPS » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..c5821bba3d8bed947171ce70c069c4db8e56895f 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);
+ 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)
+ *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,
« no previous file with comments | « chrome/test/base/ui_test_utils.h ('k') | chrome/test/data/nacl/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698