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

Side by Side Diff: chrome/test/webdriver/webdriver_util_unittest.cc

Issue 11359217: Move scoped_temp_dir from base to base/files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <set> 5 #include <set>
6 #include <string> 6 #include <string>
7 7
8 #include "base/base64.h" 8 #include "base/base64.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/scoped_temp_dir.h" 11 #include "base/files/scoped_temp_dir.h"
12 #include "chrome/test/webdriver/webdriver_util.h" 12 #include "chrome/test/webdriver/webdriver_util.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 namespace webdriver { 15 namespace webdriver {
16 16
17 TEST(RandomIDTest, CanGenerateSufficientlyRandomIDs) { 17 TEST(RandomIDTest, CanGenerateSufficientlyRandomIDs) {
18 std::set<std::string> generated_ids; 18 std::set<std::string> generated_ids;
19 for (int i = 0; i < 10000; ++i) { 19 for (int i = 0; i < 10000; ++i) {
20 std::string id = GenerateRandomID(); 20 std::string id = GenerateRandomID();
21 ASSERT_EQ(32u, id.length()); 21 ASSERT_EQ(32u, id.length());
22 ASSERT_TRUE(generated_ids.end() == generated_ids.find(id)) 22 ASSERT_TRUE(generated_ids.end() == generated_ids.find(id))
23 << "Generated duplicate ID: " << id 23 << "Generated duplicate ID: " << id
24 << " on iteration " << i; 24 << " on iteration " << i;
25 generated_ids.insert(id); 25 generated_ids.insert(id);
26 } 26 }
27 } 27 }
28 28
29 TEST(ZipFileTest, ZipEntryToZipArchive) { 29 TEST(ZipFileTest, ZipEntryToZipArchive) {
30 ScopedTempDir temp_dir; 30 base::ScopedTempDir temp_dir;
31 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 31 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
32 std::string data; 32 std::string data;
33 // A zip entry sent from a Java WebDriver client (v2.20) that contains a 33 // A zip entry sent from a Java WebDriver client (v2.20) that contains a
34 // file with the contents "COW\n". 34 // file with the contents "COW\n".
35 const char* kBase64ZipEntry = 35 const char* kBase64ZipEntry =
36 "UEsDBBQACAAIAJpyXEAAAAAAAAAAAAAAAAAEAAAAdGVzdHP2D+" 36 "UEsDBBQACAAIAJpyXEAAAAAAAAAAAAAAAAAEAAAAdGVzdHP2D+"
37 "cCAFBLBwi/wAzGBgAAAAQAAAA="; 37 "cCAFBLBwi/wAzGBgAAAAQAAAA=";
38 ASSERT_TRUE(base::Base64Decode(kBase64ZipEntry, &data)); 38 ASSERT_TRUE(base::Base64Decode(kBase64ZipEntry, &data));
39 FilePath file; 39 FilePath file;
40 std::string error_msg; 40 std::string error_msg;
41 ASSERT_TRUE(UnzipSoleFile(temp_dir.path(), data, &file, &error_msg)) 41 ASSERT_TRUE(UnzipSoleFile(temp_dir.path(), data, &file, &error_msg))
42 << error_msg; 42 << error_msg;
43 std::string contents; 43 std::string contents;
44 ASSERT_TRUE(file_util::ReadFileToString(file, &contents)); 44 ASSERT_TRUE(file_util::ReadFileToString(file, &contents));
45 ASSERT_STREQ("COW\n", contents.c_str()); 45 ASSERT_STREQ("COW\n", contents.c_str());
46 } 46 }
47 47
48 } // namespace webdriver 48 } // namespace webdriver
OLDNEW
« no previous file with comments | « chrome/test/webdriver/webdriver_util.cc ('k') | chrome_frame/test/dll_redirector_loading_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698