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_
11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/message_loop/message_loop.h"
14 #include "components/sessions/session_id.h"
27 class SerializedNavigationEntry
;
30 // A simple class that makes writing SessionService related tests easier.
32 class SessionServiceTestHelper
{
34 SessionServiceTestHelper();
35 explicit SessionServiceTestHelper(SessionService
* service
);
36 ~SessionServiceTestHelper();
38 void PrepareTabInWindow(const SessionID
& window_id
,
39 const SessionID
& tab_id
,
43 void SetTabExtensionAppID(const SessionID
& window_id
,
44 const SessionID
& tab_id
,
45 const std::string
& extension_app_id
);
47 void SetTabUserAgentOverride(const SessionID
& window_id
,
48 const SessionID
& tab_id
,
49 const std::string
& user_agent_override
);
51 void SetForceBrowserNotAliveWithNoWindows(
52 bool force_browser_not_alive_with_no_windows
);
54 // Reads the contents of the last session.
55 void ReadWindows(std::vector
<SessionWindow
*>* windows
,
56 SessionID::id_type
* active_window_id
);
58 void AssertTabEquals(SessionID
& window_id
,
63 const SessionTab
& session_tab
);
65 void AssertTabEquals(int visual_index
,
68 const SessionTab
& session_tab
);
70 void AssertNavigationEquals(
71 const sessions::SerializedNavigationEntry
& expected
,
72 const sessions::SerializedNavigationEntry
& actual
);
74 void AssertSingleWindowWithSingleTab(
75 const std::vector
<SessionWindow
*>& windows
,
78 void SetService(SessionService
* service
);
79 SessionService
* ReleaseService() { return service_
.release(); }
80 SessionService
* service() { return service_
.get(); }
82 SessionBackend
* backend();
84 void RunTaskOnBackendThread(const tracked_objects::Location
& from_here
,
85 const base::Closure
& task
);
88 scoped_ptr
<SessionService
> service_
;
90 DISALLOW_COPY_AND_ASSIGN(SessionServiceTestHelper
);
93 #endif // CHROME_BROWSER_SESSIONS_SESSION_SERVICE_TEST_HELPER_H_