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

Side by Side Diff: components/safe_browsing_db/prefix_set_unittest.cc

Issue 1420053005: Move code in components/safe_browsing_db and chrome/browser/s_b/ under the safe_browsing namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@02_components_move
Patch Set: Other minor fixes incl. using "using safe_browsing::ClassName" instead of safe_browsing::ClassName everywhere. Created 5 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
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 "components/safe_browsing_db/prefix_set.h" 5 #include "components/safe_browsing_db/prefix_set.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 11
12 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
13 #include "base/files/scoped_file.h" 13 #include "base/files/scoped_file.h"
14 #include "base/files/scoped_temp_dir.h" 14 #include "base/files/scoped_temp_dir.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/md5.h" 16 #include "base/md5.h"
17 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
18 #include "base/path_service.h" 18 #include "base/path_service.h"
19 #include "base/rand_util.h" 19 #include "base/rand_util.h"
20 #include "base/strings/string_number_conversions.h" 20 #include "base/strings/string_number_conversions.h"
21 #include "base/strings/string_util.h" 21 #include "base/strings/string_util.h"
22 #include "components/safe_browsing_db/util.h" 22 #include "components/safe_browsing_db/util.h"
23 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
24 #include "testing/platform_test.h" 24 #include "testing/platform_test.h"
25 25
26 namespace { 26 namespace safe_browsing {
27 27
28 const SBPrefix kHighBitClear = 1000u * 1000u * 1000u; 28 const SBPrefix kHighBitClear = 1000u * 1000u * 1000u;
29 const SBPrefix kHighBitSet = 3u * 1000u * 1000u * 1000u; 29 const SBPrefix kHighBitSet = 3u * 1000u * 1000u * 1000u;
30 30
31 } // namespace
mattm 2015/11/11 01:10:16 Keep the anon namespace inside the new namespace.
vakh (old account. dont use) 2015/11/11 18:59:53 Done.
32
33 namespace safe_browsing {
34
35 class PrefixSetTest : public PlatformTest { 31 class PrefixSetTest : public PlatformTest {
36 protected: 32 protected:
37 // Constants for the v1 format. 33 // Constants for the v1 format.
38 static const size_t kMagicOffset = 0 * sizeof(uint32); 34 static const size_t kMagicOffset = 0 * sizeof(uint32);
39 static const size_t kVersionOffset = 1 * sizeof(uint32); 35 static const size_t kVersionOffset = 1 * sizeof(uint32);
40 static const size_t kIndexSizeOffset = 2 * sizeof(uint32); 36 static const size_t kIndexSizeOffset = 2 * sizeof(uint32);
41 static const size_t kDeltasSizeOffset = 3 * sizeof(uint32); 37 static const size_t kDeltasSizeOffset = 3 * sizeof(uint32);
42 static const size_t kFullHashesSizeOffset = 4 * sizeof(uint32); 38 static const size_t kFullHashesSizeOffset = 4 * sizeof(uint32);
43 static const size_t kPayloadOffset = 5 * sizeof(uint32); 39 static const size_t kPayloadOffset = 5 * sizeof(uint32);
44 40
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 const SBFullHash kHash2 = SBFullHashForString("www.evil.com/phishing.html"); 715 const SBFullHash kHash2 = SBFullHashForString("www.evil.com/phishing.html");
720 716
721 EXPECT_TRUE(prefix_set->Exists(kHash1)); 717 EXPECT_TRUE(prefix_set->Exists(kHash1));
722 EXPECT_TRUE(prefix_set->Exists(kHash2)); 718 EXPECT_TRUE(prefix_set->Exists(kHash2));
723 EXPECT_FALSE(prefix_set->PrefixExists(kHash1.prefix)); 719 EXPECT_FALSE(prefix_set->PrefixExists(kHash1.prefix));
724 EXPECT_FALSE(prefix_set->PrefixExists(kHash2.prefix)); 720 EXPECT_FALSE(prefix_set->PrefixExists(kHash2.prefix));
725 } 721 }
726 #endif 722 #endif
727 723
728 } // namespace safe_browsing 724 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698