blob: 34f638a1d694f22fa71cc3829cc9813828558cc1 (
plain)
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
|
// Tests for tableview-related things
// Right now it's just testing the serialize-unserialize of the header state code.
#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include <QtDebug>
#include "proto/headers.pb.h"
#include "widget/wtracktableviewheader.h"
class HeaderViewStateTest : public testing::Test {
};
TEST_F(HeaderViewStateTest, RoundTrip) {
mixxx::library::HeaderViewState headerViewState_pb;
mixxx::library::HeaderViewState::HeaderState* header_state_pb =
headerViewState_pb.add_header_state();
header_state_pb->set_hidden(true);
header_state_pb->set_size(50);
header_state_pb->set_logical_index(10);
header_state_pb->set_visual_index(2);
header_state_pb->set_column_name("MyCol");
header_state_pb =
headerViewState_pb.add_header_state();
header_state_pb->set_hidden(false);
header_state_pb->set_size(22);
header_state_pb->set_logical_index(6);
header_state_pb->set_visual_index(3);
header_state_pb->set_column_name("MyOtherCol");
headerViewState_pb.set_sort_indicator_shown(true);
headerViewState_pb.set_sort_indicator_section(1);
headerViewState_pb.set_sort_order(Qt::DescendingOrder);
// Create a HeaderViewState based on the proto.
HeaderViewState view_state(headerViewState_pb);
// Get a serialized form of the state.
QString saved_state = view_state.saveState();
// Initialize a new state object with the saved state.
HeaderViewState loaded_state(saved_state);
// Compare the old saved state with the new one.
ASSERT_EQ(saved_state, loaded_state.saveState());
// Ensure that the serialization is not bullshit.
ASSERT_NE("", saved_state);
}
TEST_F(HeaderViewStateTest, GoodHeaderState) {
const QString kGoodSerializedProto("ChEIARAAGAEgACoHcHJldmlldwoICAAQSxgEIAE"
"KEggBEAAYAiACKghjb3ZlcmFydAoICAEQABgDIAMKCAgBEAAYBSAECggIABBaGBYgB"
"QoICAEQABgGIAYKCQgAEPwBGBcgBwoJCAAQvAEYByAICgkIABDmARgIIAkKCAgBEAA"
"YCSAKCggIARAAGAogCwoJCAAQkwQYGSAMCggIARAAGAwgDQoICAEQABgNIA4KCAgBE"
"AAYDiAPCggIARAAGBAgEAoICAAQVxgRIBEKCAgBEAAYEiASCggIABBGGBMgEwoICAA"
"QMhgPIBQKCAgAEHUYCyAVCggIARAAGBQgFgoICAAQNxgVIBcKCAgBEAAYGCAYCggIA"
"RAAGBogGQoICAEQABgbIBoKCAgBEAAYHCAbCggIARAAGAAgHAoICAEQABgdIB0KCAg"
"BEAAYHiAeEAEYFiAB");
HeaderViewState view_state(kGoodSerializedProto);
ASSERT_TRUE(view_state.healthy());
ASSERT_EQ(kGoodSerializedProto, view_state.saveState());
}
TEST_F(HeaderViewStateTest, BadHeaderState) {
HeaderViewState view_state("BLAHBLAHBLAHBAD");
ASSERT_FALSE(view_state.healthy());
}
|