Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / sessions / session_service_test_helper.h
blobac029519b415268ad614dc4f1533a93272755d18
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_SESSIONS_SESSION_SERVICE_TEST_HELPER_H_
6 #define CHROME_BROWSER_SESSIONS_SESSION_SERVICE_TEST_HELPER_H_
8 #include <string>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "chrome/browser/sessions/session_id.h"
15 class SessionBackend;
16 class SessionCommand;
17 class SessionService;
18 struct SessionTab;
19 struct SessionWindow;
21 namespace sessions {
22 class SerializedNavigationEntry;
25 // A simple class that makes writing SessionService related tests easier.
27 class SessionServiceTestHelper {
28 public:
29 explicit SessionServiceTestHelper();
30 explicit SessionServiceTestHelper(SessionService* service);
31 ~SessionServiceTestHelper();
33 void PrepareTabInWindow(const SessionID& window_id,
34 const SessionID& tab_id,
35 int visual_index,
36 bool select);
38 void SetTabExtensionAppID(const SessionID& window_id,
39 const SessionID& tab_id,
40 const std::string& extension_app_id);
42 void SetTabUserAgentOverride(const SessionID& window_id,
43 const SessionID& tab_id,
44 const std::string& user_agent_override);
46 void SetForceBrowserNotAliveWithNoWindows(
47 bool force_browser_not_alive_with_no_windows);
49 // Reads the contents of the last session.
50 void ReadWindows(std::vector<SessionWindow*>* windows,
51 SessionID::id_type* active_window_id);
53 void AssertTabEquals(SessionID& window_id,
54 SessionID& tab_id,
55 int visual_index,
56 int nav_index,
57 size_t nav_count,
58 const SessionTab& session_tab);
60 void AssertTabEquals(int visual_index,
61 int nav_index,
62 size_t nav_count,
63 const SessionTab& session_tab);
65 void AssertNavigationEquals(
66 const sessions::SerializedNavigationEntry& expected,
67 const sessions::SerializedNavigationEntry& actual);
69 void AssertSingleWindowWithSingleTab(
70 const std::vector<SessionWindow*>& windows,
71 size_t nav_count);
73 void SetService(SessionService* service);
74 SessionService* ReleaseService() { return service_.release(); }
75 SessionService* service() { return service_.get(); }
77 SessionBackend* backend();
79 private:
80 scoped_ptr<SessionService> service_;
82 DISALLOW_COPY_AND_ASSIGN(SessionServiceTestHelper);
85 #endif // CHROME_BROWSER_SESSIONS_SESSION_SERVICE_TEST_HELPER_H_