on 436b607 help sign in
unity8/tests/mocks/LightDM/liblightdm/UsersModelPrivate.cpp
104 lines 3.5 kB history raw
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
17#include "UsersModelPrivate.h"
18#include "UsersModel.h"
20namespace QLightDM
23UsersModelPrivate::UsersModelPrivate(UsersModel* parent)
24 : mockMode("single")
25 , q_ptr(parent)
27 char *envMockMode = getenv("LIBLIGHTDM_MOCK_MODE");
28 if (envMockMode) {
29 mockMode = envMockMode;
30 }
31 resetEntries();
34void UsersModelPrivate::resetEntries()
36 Q_Q(UsersModel);
38 q->beginResetModel();
40 if (mockMode == "single") {
41 resetEntries_single();
42 } else if (mockMode == "single-passphrase") {
43 resetEntries_singlePassphrase();
44 } else if (mockMode == "single-pin") {
45 resetEntries_singlePin();
46 } else if (mockMode == "full") {
47 resetEntries_full();
48 }
50 q->endResetModel();
53void UsersModelPrivate::resetEntries_single()
55 entries =
56 {
57 { "single", "Single User", 0, 0, false, false, 0, 0 },
58 };
61void UsersModelPrivate::resetEntries_singlePassphrase()
63 entries =
64 {
65 { "single", "Single User", 0, 0, false, false, 0, 0 },
66 };
69void UsersModelPrivate::resetEntries_singlePin()
71 entries =
72 {
73 { "has-pin", "Has PIN", 0, 0, false, false, 0, 0 },
74 };
77void UsersModelPrivate::resetEntries_full()
79 entries =
80 {
81 { "has-password", "Has Password", 0, 0, false, false, 0, 0 },
82 { "has-pin", "Has PIN", 0, 0, false, false, 0, 0 },
83 { "different-prompt", "Different Prompt", 0, 0, false, false, 0, 0 },
84 { "no-password", "No Password", 0, 0, false, false, 0, 0 },
85 { "auth-error", "Auth Error", 0, 0, false, false, 0, 0 },
86 { "two-factor", "Two Factor", 0, 0, false, false, 0, 0 },
87 { "info-prompt", "Info Prompt", 0, 0, false, false, 0, 0 },
88 { "html-info-prompt", "HTML Info Prompt", 0, 0, false, false, 0, 0 },
89 { "long-info-prompt", "Long Info Prompt", 0, 0, false, false, 0, 0 },
90 { "wide-info-prompt", "Wide Info Prompt", 0, 0, false, false, 0, 0 },
91 { "multi-info-prompt", "Multi Info Prompt", 0, 0, false, false, 0, 0 },
92 { "long-name", "Long name (far far too long to fit)", 0, 0, false, false, 0, 0 },
93 { "color-background", "Color Background", "#dd4814", 0, false, false, 0, 0 },
94 // white and black are a bit redundant, but useful for manually testing if UI is still readable
95 { "white-background", "White Background", "#ffffff", 0, false, false, 0, 0 },
96 { "black-background", "Black Background", "#000000", 0, false, false, 0, 0 },
97 { "no-background", "No Background", "", 0, false, false, 0, 0 },
98 { "unicode", "가나다라마", 0, 0, false, false, 0, 0 },
99 { "no-response", "No Response", 0, 0, false, false, 0, 0 },
100 { "empty-name", "", 0, 0, false, false, 0, 0 },
101 };
104} // namespace QLightDM