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"
23 class SerializedNavigationEntry
;
29 // A simple class that makes writing SessionService related tests easier.
31 class SessionServiceTestHelper
{
33 SessionServiceTestHelper();
34 explicit SessionServiceTestHelper(SessionService
* service
);
35 ~SessionServiceTestHelper();
37 void PrepareTabInWindow(const SessionID
& window_id
,
38 const SessionID
& tab_id
,
42 void SetTabExtensionAppID(const SessionID
& window_id
,
43 const SessionID
& tab_id
,
44 const std::string
& extension_app_id
);
46 void SetTabUserAgentOverride(const SessionID
& window_id
,
47 const SessionID
& tab_id
,
48 const std::string
& user_agent_override
);
50 void SetForceBrowserNotAliveWithNoWindows(
51 bool force_browser_not_alive_with_no_windows
);
53 // Reads the contents of the last session.
54 void ReadWindows(std::vector
<sessions::SessionWindow
*>* windows
,
55 SessionID::id_type
* active_window_id
);
57 void AssertTabEquals(const SessionID
& window_id
,
58 const SessionID
& tab_id
,
62 const sessions::SessionTab
& session_tab
);
64 void AssertTabEquals(int visual_index
,
67 const sessions::SessionTab
& session_tab
);
69 void AssertNavigationEquals(
70 const sessions::SerializedNavigationEntry
& expected
,
71 const sessions::SerializedNavigationEntry
& actual
);
73 void AssertSingleWindowWithSingleTab(
74 const std::vector
<sessions::SessionWindow
*>& windows
,
77 void SetService(SessionService
* service
);
78 SessionService
* ReleaseService();
79 SessionService
* service() { return service_
.get(); }
81 void RunTaskOnBackendThread(const tracked_objects::Location
& from_here
,
82 const base::Closure
& task
);
85 scoped_ptr
<SessionService
> service_
;
87 DISALLOW_COPY_AND_ASSIGN(SessionServiceTestHelper
);
90 #endif // CHROME_BROWSER_SESSIONS_SESSION_SERVICE_TEST_HELPER_H_