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

Side by Side Diff: chrome/browser/safe_browsing/prefix_set_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 "chrome/browser/safe_browsing/prefix_set.h" 5 #include "chrome/browser/safe_browsing/prefix_set.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 9
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/files/scoped_temp_dir.h"
11 #include "base/logging.h" 12 #include "base/logging.h"
12 #include "base/md5.h" 13 #include "base/md5.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
14 #include "base/rand_util.h" 15 #include "base/rand_util.h"
15 #include "base/scoped_temp_dir.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "testing/platform_test.h" 17 #include "testing/platform_test.h"
18 18
19 namespace { 19 namespace {
20 20
21 class PrefixSetTest : public PlatformTest { 21 class PrefixSetTest : public PlatformTest {
22 protected: 22 protected:
23 // Constants for the v1 format. 23 // Constants for the v1 format.
24 static const size_t kMagicOffset = 0 * sizeof(uint32); 24 static const size_t kMagicOffset = 0 * sizeof(uint32);
25 static const size_t kVersionOffset = 1 * sizeof(uint32); 25 static const size_t kVersionOffset = 1 * sizeof(uint32);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 file.reset(); 139 file.reset();
140 140
141 int64 new_size_64; 141 int64 new_size_64;
142 ASSERT_TRUE(file_util::GetFileSize(filename, &new_size_64)); 142 ASSERT_TRUE(file_util::GetFileSize(filename, &new_size_64));
143 ASSERT_EQ(new_size_64, size_64); 143 ASSERT_EQ(new_size_64, size_64);
144 } 144 }
145 145
146 // Tests should not modify this shared resource. 146 // Tests should not modify this shared resource.
147 static std::vector<SBPrefix> shared_prefixes_; 147 static std::vector<SBPrefix> shared_prefixes_;
148 148
149 ScopedTempDir temp_dir_; 149 base::ScopedTempDir temp_dir_;
150 }; 150 };
151 151
152 std::vector<SBPrefix> PrefixSetTest::shared_prefixes_; 152 std::vector<SBPrefix> PrefixSetTest::shared_prefixes_;
153 153
154 // Test that a small sparse random input works. 154 // Test that a small sparse random input works.
155 TEST_F(PrefixSetTest, Baseline) { 155 TEST_F(PrefixSetTest, Baseline) {
156 safe_browsing::PrefixSet prefix_set(shared_prefixes_); 156 safe_browsing::PrefixSet prefix_set(shared_prefixes_);
157 CheckPrefixes(prefix_set, shared_prefixes_); 157 CheckPrefixes(prefix_set, shared_prefixes_);
158 } 158 }
159 159
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 file_util::ScopedFILE file(file_util::OpenFile(filename, "ab")); 458 file_util::ScopedFILE file(file_util::OpenFile(filename, "ab"));
459 const char buf[] = "im in ur base, killing ur d00dz."; 459 const char buf[] = "im in ur base, killing ur d00dz.";
460 ASSERT_EQ(strlen(buf), fwrite(buf, 1, strlen(buf), file.get())); 460 ASSERT_EQ(strlen(buf), fwrite(buf, 1, strlen(buf), file.get()));
461 file.reset(); 461 file.reset();
462 scoped_ptr<safe_browsing::PrefixSet> 462 scoped_ptr<safe_browsing::PrefixSet>
463 prefix_set(safe_browsing::PrefixSet::LoadFile(filename)); 463 prefix_set(safe_browsing::PrefixSet::LoadFile(filename));
464 ASSERT_FALSE(prefix_set.get()); 464 ASSERT_FALSE(prefix_set.get());
465 } 465 }
466 466
467 } // namespace 467 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698