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

Unified Diff: chrome/test/webdriver/webdriver_util_unittest.cc

Issue 9515005: [chromedriver] Add command for uploading a file to a remote ChromeDriver server, (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 10 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/webdriver/webdriver_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/webdriver/webdriver_util_unittest.cc
diff --git a/chrome/test/webdriver/webdriver_util_unittest.cc b/chrome/test/webdriver/webdriver_util_unittest.cc
index c80a3d79f83d87cfa9c867429d2792767cc86c00..7c824834d7342b815c853521b9b3b6237a217df4 100644
--- a/chrome/test/webdriver/webdriver_util_unittest.cc
+++ b/chrome/test/webdriver/webdriver_util_unittest.cc
@@ -1,17 +1,23 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
#include <set>
#include <string>
+#include "base/base64.h"
+#include "base/file_path.h"
+#include "base/file_util.h"
+#include "base/scoped_temp_dir.h"
#include "chrome/test/webdriver/webdriver_util.h"
#include "testing/gtest/include/gtest/gtest.h"
+namespace webdriver {
+
TEST(RandomIDTest, CanGenerateSufficientlyRandomIDs) {
std::set<std::string> generated_ids;
for (int i = 0; i < 10000; ++i) {
- std::string id = webdriver::GenerateRandomID();
+ std::string id = GenerateRandomID();
ASSERT_EQ(32u, id.length());
ASSERT_TRUE(generated_ids.end() == generated_ids.find(id))
<< "Generated duplicate ID: " << id
@@ -19,3 +25,24 @@ TEST(RandomIDTest, CanGenerateSufficientlyRandomIDs) {
generated_ids.insert(id);
}
}
+
+TEST(ZipFileTest, ZipEntryToZipArchive) {
+ ScopedTempDir temp_dir;
+ ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
+ std::string data;
+ // A zip entry sent from a Java WebDriver client (v2.20) that contains a
+ // file with the contents "COW\n".
+ const char* kBase64ZipEntry =
+ "UEsDBBQACAAIAJpyXEAAAAAAAAAAAAAAAAAEAAAAdGVzdHP2D+"
+ "cCAFBLBwi/wAzGBgAAAAQAAAA=";
+ ASSERT_TRUE(base::Base64Decode(kBase64ZipEntry, &data));
+ FilePath file;
+ std::string error_msg;
+ ASSERT_TRUE(UnzipSoleFile(temp_dir.path(), data, &file, &error_msg))
+ << error_msg;
+ std::string contents;
+ ASSERT_TRUE(file_util::ReadFileToString(file, &contents));
+ ASSERT_STREQ("COW\n", contents.c_str());
+}
+
+} // namespace webdriver
« no previous file with comments | « chrome/test/webdriver/webdriver_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698