ExtensionSyncService: Properly differentiate between "pending install" and "pending...
[chromium-blink-merge.git] / components / sessions / serialized_navigation_entry_test_helper.h
blob54f070fbdb4c7e7a6fdc0435243786b51b8e5278
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.
5 #ifndef COMPONENTS_SESSIONS_SESSION_TYPES_TEST_HELPER_H_
6 #define COMPONENTS_SESSIONS_SESSION_TYPES_TEST_HELPER_H_
8 #include <string>
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"
15 class GURL;
17 namespace base {
18 class Time;
21 namespace sessions {
23 class SerializedNavigationEntry;
25 namespace test_data {
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;
48 } // namespace test_data
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);
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);
64 // Creates a SerializedNavigationEntry using the |test_data| constants above.
65 static SerializedNavigationEntry CreateNavigationForTest();
67 static void SetReferrerPolicy(int policy,
68 SerializedNavigationEntry* navigation);
70 static void SetVirtualURL(const GURL& virtual_url,
71 SerializedNavigationEntry* navigation);
73 static void SetEncodedPageState(const std::string& encoded_page_state,
74 SerializedNavigationEntry* navigation);
76 static void SetTransitionType(ui::PageTransition transition_type,
77 SerializedNavigationEntry* navigation);
79 static void SetHasPostData(bool has_post_data,
80 SerializedNavigationEntry* navigation);
82 static void SetOriginalRequestURL(const GURL& original_request_url,
83 SerializedNavigationEntry* navigation);
85 static void SetIsOverridingUserAgent(bool is_overriding_user_agent,
86 SerializedNavigationEntry* navigation);
88 static void SetTimestamp(base::Time timestamp,
89 SerializedNavigationEntry* navigation);
91 private:
92 DISALLOW_IMPLICIT_CONSTRUCTORS(SerializedNavigationEntryTestHelper);
95 } // sessions
97 #endif // COMPONENTS_SESSIONS_SESSION_TYPES_TEST_HELPER_H_