OLD | NEW |
| (Empty) |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef COMPONENTS_SESSIONS_SESSION_TYPES_TEST_HELPER_H_ | |
6 #define COMPONENTS_SESSIONS_SESSION_TYPES_TEST_HELPER_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "base/strings/string16.h" | |
12 #include "base/time/time.h" | |
13 #include "ui/base/page_transition_types.h" | |
14 | |
15 class GURL; | |
16 | |
17 namespace base { | |
18 class Time; | |
19 } | |
20 | |
21 namespace sessions { | |
22 | |
23 class SerializedNavigationEntry; | |
24 | |
25 namespace test_data { | |
26 | |
27 extern const int kIndex; | |
28 extern const int kUniqueID; | |
29 extern const GURL kReferrerURL; | |
30 extern const int kReferrerPolicy; | |
31 extern const GURL kVirtualURL; | |
32 extern const base::string16 kTitle; | |
33 extern const std::string kEncodedPageState; | |
34 extern const ui::PageTransition kTransitionType; | |
35 extern const bool kHasPostData; | |
36 extern const int64 kPostID; | |
37 extern const GURL kOriginalRequestURL; | |
38 extern const bool kIsOverridingUserAgent; | |
39 extern const base::Time kTimestamp; | |
40 extern const base::string16 kSearchTerms; | |
41 extern const GURL kFaviconURL; | |
42 extern const int kHttpStatusCode; | |
43 extern const GURL kRedirectURL0; | |
44 extern const GURL kRedirectURL1; | |
45 extern const GURL kOtherURL; | |
46 extern const int kPageID; | |
47 | |
48 } // namespace test_data | |
49 | |
50 // Set of test functions to manipulate a SerializedNavigationEntry. | |
51 class SerializedNavigationEntryTestHelper { | |
52 public: | |
53 // Compares the two entries. This uses EXPECT_XXX on each member, if your test | |
54 // needs to stop after this wrap calls to this in EXPECT_NO_FATAL_FAILURE. | |
55 static void ExpectNavigationEquals(const SerializedNavigationEntry& expected, | |
56 const SerializedNavigationEntry& actual); | |
57 | |
58 // Creates a SerializedNavigationEntry with the given URL and title and some | |
59 // common values for the other fields. | |
60 static SerializedNavigationEntry CreateNavigation( | |
61 const std::string& virtual_url, | |
62 const std::string& title); | |
63 | |
64 // Creates a SerializedNavigationEntry using the |test_data| constants above. | |
65 static SerializedNavigationEntry CreateNavigationForTest(); | |
66 | |
67 static void SetReferrerPolicy(int policy, | |
68 SerializedNavigationEntry* navigation); | |
69 | |
70 static void SetVirtualURL(const GURL& virtual_url, | |
71 SerializedNavigationEntry* navigation); | |
72 | |
73 static void SetEncodedPageState(const std::string& encoded_page_state, | |
74 SerializedNavigationEntry* navigation); | |
75 | |
76 static void SetTransitionType(ui::PageTransition transition_type, | |
77 SerializedNavigationEntry* navigation); | |
78 | |
79 static void SetHasPostData(bool has_post_data, | |
80 SerializedNavigationEntry* navigation); | |
81 | |
82 static void SetOriginalRequestURL(const GURL& original_request_url, | |
83 SerializedNavigationEntry* navigation); | |
84 | |
85 static void SetIsOverridingUserAgent(bool is_overriding_user_agent, | |
86 SerializedNavigationEntry* navigation); | |
87 | |
88 static void SetTimestamp(base::Time timestamp, | |
89 SerializedNavigationEntry* navigation); | |
90 | |
91 private: | |
92 DISALLOW_IMPLICIT_CONSTRUCTORS(SerializedNavigationEntryTestHelper); | |
93 }; | |
94 | |
95 } // sessions | |
96 | |
97 #endif // COMPONENTS_SESSIONS_SESSION_TYPES_TEST_HELPER_H_ | |
OLD | NEW |