1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_SESSIONS_SESSION_SERVICE_TEST_HELPER_H_
#define CHROME_BROWSER_SESSIONS_SESSION_SERVICE_TEST_HELPER_H_
#include <string>
#include <vector>
#include "base/ref_counted.h"
class SessionBackend;
class SessionCommand;
class SessionID;
class SessionService;
struct SessionTab;
struct SessionWindow;
class TabNavigation;
// A simple class that makes writing SessionService related tests easier.
class SessionServiceTestHelper {
public:
explicit SessionServiceTestHelper() {}
explicit SessionServiceTestHelper(SessionService* service)
: service_(service) {}
void RestoreSessionFromCommands(const std::vector<SessionCommand*>& commands,
std::vector<SessionWindow*>* valid_windows);
void PrepareTabInWindow(const SessionID& window_id,
const SessionID& tab_id,
int visual_index,
bool select);
void SetTabExtensionAppID(const SessionID& window_id,
const SessionID& tab_id,
const std::string& extension_app_id);
// Reads the contents of the last session.
void ReadWindows(std::vector<SessionWindow*>* windows);
void AssertTabEquals(SessionID& window_id,
SessionID& tab_id,
int visual_index,
int nav_index,
size_t nav_count,
const SessionTab& session_tab);
void AssertTabEquals(int visual_index,
int nav_index,
size_t nav_count,
const SessionTab& session_tab);
void AssertNavigationEquals(const TabNavigation& expected,
const TabNavigation& actual);
void AssertSingleWindowWithSingleTab(
const std::vector<SessionWindow*>& windows,
size_t nav_count);
void set_service(SessionService* service) { service_ = service; }
SessionService* service() { return service_.get(); }
SessionBackend* backend();
private:
scoped_refptr<SessionService> service_;
DISALLOW_COPY_AND_ASSIGN(SessionServiceTestHelper);
};
#endif // CHROME_BROWSER_SESSIONS_SESSION_SERVICE_TEST_HELPER_H_
|