29 #include <hgwidgets/hgmediawall.h> |
29 #include <hgwidgets/hgmediawall.h> |
30 |
30 |
31 Q_DECLARE_METATYPE(QItemSelection) |
31 Q_DECLARE_METATYPE(QItemSelection) |
32 Q_DECLARE_METATYPE(QModelIndex) |
32 Q_DECLARE_METATYPE(QModelIndex) |
33 |
33 |
34 static const QPointF grid_portrait_pos0(70, 30); |
34 static const QPointF grid_portrait_pos0(60, 60); |
35 static const QPointF grid_portrait_pos1(180, 30); |
35 static const QPointF grid_portrait_pos1(180, 60); |
36 static const QPointF grid_portrait_pos2(280, 30); |
36 static const QPointF grid_portrait_pos2(300, 60); |
37 static const QPointF grid_portrait_pos3(70, 120); |
37 static const QPointF grid_portrait_pos3(60, 180); |
38 static const QPointF grid_portrait_pos4(180, 120); |
38 static const QPointF grid_portrait_pos4(180, 180); |
39 static const QPointF grid_portrait_pos5(280, 120); |
39 static const QPointF grid_portrait_pos5(300, 180); |
40 static const QPointF grid_portrait_pos6(70, 200); |
40 static const QPointF grid_portrait_pos6(60, 300); |
41 static const QPointF grid_portrait_pos7(180, 200); |
41 static const QPointF grid_portrait_pos7(180, 300); |
42 static const QPointF grid_portrait_pos8(280, 200); |
42 static const QPointF grid_portrait_pos8(300, 300); |
43 |
|
44 // These work with 360x640 resolution |
|
45 static const QPointF expected_label_pos_above_alone(180, 144); |
|
46 static const QPointF expected_label_pos_above_top(180, 132); |
|
47 static const QPointF expected_label_pos_above_bottom(180, 163); |
|
48 static const QPointF expected_label_pos_below_alone(180, 324); |
|
49 static const QPointF expected_label_pos_below_top(180, 312); |
|
50 static const QPointF expected_label_pos_below_bottom(180, 342); |
|
51 |
43 |
52 static const int default_delay(1500); |
44 static const int default_delay(1500); |
53 |
45 |
54 class TestGanesWidgets : public QObject |
46 class TestGanesWidgets : public QObject |
55 { |
47 { |
1934 |
1925 |
1935 delete mWindow; |
1926 delete mWindow; |
1936 mWindow = 0; |
1927 mWindow = 0; |
1937 } |
1928 } |
1938 |
1929 |
1939 void TestGanesWidgets::test_labelPositionsCoverFlow() |
1930 void TestGanesWidgets::test_labelFontSpecsCoverFlow() |
1940 { |
1931 { |
1941 mWindow = new HbMainWindow; |
1932 mWindow = new HbMainWindow; |
1942 mMediawall = new HgMediawall(); |
1933 mMediawall = new HgMediawall(); |
1943 |
1934 |
1944 TestModel model; |
1935 TestModel model; |
1945 model.generateItems(50); |
1936 model.generateItems(50); |
1946 mWindow->addView(mMediawall); |
1937 mWindow->addView(mMediawall); |
1947 mMediawall->setModel(&model); |
1938 mMediawall->setModel(&model); |
1948 mWindow->show(); |
1939 mWindow->show(); |
1949 |
1940 |
1950 mMediawall->setTitlePosition(HgMediawall::PositionNone); |
1941 mMediawall->setTitleFontSpec(HbFontSpec(HbFontSpec::Primary)); |
1951 mMediawall->setDescriptionPosition(HgMediawall::PositionNone); |
1942 QVERIFY(mMediawall->titleFontSpec() == HbFontSpec(HbFontSpec::Primary)); |
1952 QVERIFY(mMediawall->titlePosition() == HgMediawall::PositionNone); |
1943 |
1953 QVERIFY(mMediawall->descriptionPosition() == HgMediawall::PositionNone); |
1944 mMediawall->setDescriptionFontSpec(HbFontSpec(HbFontSpec::Secondary)); |
1954 |
1945 QVERIFY(mMediawall->descriptionFontSpec() == HbFontSpec(HbFontSpec::Secondary)); |
1955 // This updates the title and description label. But how to test they are in correct positions? |
1946 |
1956 mMediawall->setCurrentIndex(model.index(1, 0)); |
1947 mMediawall->setTitleFontSpec(HbFontSpec(HbFontSpec::Title)); |
1957 QTest::qWait(1000); |
1948 QVERIFY(mMediawall->titleFontSpec() == HbFontSpec(HbFontSpec::Title)); |
1958 |
1949 |
1959 mMediawall->setDescriptionPosition(HgMediawall::PositionAboveImage); |
1950 mMediawall->setDescriptionFontSpec(HbFontSpec(HbFontSpec::PrimarySmall)); |
1960 QVERIFY(mMediawall->titlePosition() == HgMediawall::PositionNone); |
1951 QVERIFY(mMediawall->descriptionFontSpec() == HbFontSpec(HbFontSpec::PrimarySmall)); |
1961 QVERIFY(mMediawall->descriptionPosition() == HgMediawall::PositionAboveImage); |
1952 |
1962 mMediawall->setCurrentIndex(model.index(2, 0)); |
1953 QTest::qWait(2000); |
1963 QTest::qWait(1000); |
1954 |
1964 QVERIFY(checkLabelAt(mWindow, expected_label_pos_above_alone, "Secondary 2")); |
1955 delete mWindow; |
1965 |
1956 mWindow = 0; |
1966 mMediawall->setDescriptionPosition(HgMediawall::PositionBelowImage); |
1957 } |
1967 QVERIFY(mMediawall->titlePosition() == HgMediawall::PositionNone); |
1958 |
1968 QVERIFY(mMediawall->descriptionPosition() == HgMediawall::PositionBelowImage); |
1959 void TestGanesWidgets::test_resetModelCoverFlow() |
1969 mMediawall->setCurrentIndex(model.index(3, 0)); |
|
1970 QTest::qWait(1000); |
|
1971 QVERIFY(checkLabelAt(mWindow, expected_label_pos_below_alone, "Secondary 3")); |
|
1972 |
|
1973 mMediawall->setTitlePosition(HgMediawall::PositionAboveImage); |
|
1974 QVERIFY(mMediawall->titlePosition() == HgMediawall::PositionAboveImage); |
|
1975 QVERIFY(mMediawall->descriptionPosition() == HgMediawall::PositionBelowImage); |
|
1976 mMediawall->setCurrentIndex(model.index(4, 0)); |
|
1977 QTest::qWait(1000); |
|
1978 QVERIFY(checkLabelAt(mWindow, expected_label_pos_above_alone, "Primary 4")); |
|
1979 QVERIFY(checkLabelAt(mWindow, expected_label_pos_below_alone, "Secondary 4")); |
|
1980 |
|
1981 mMediawall->setDescriptionPosition(HgMediawall::PositionAboveImage); |
|
1982 QVERIFY(mMediawall->titlePosition() == HgMediawall::PositionAboveImage); |
|
1983 QVERIFY(mMediawall->descriptionPosition() == HgMediawall::PositionAboveImage); |
|
1984 mMediawall->setCurrentIndex(model.index(5, 0)); |
|
1985 QTest::qWait(1000); |
|
1986 QVERIFY(checkLabelAt(mWindow, expected_label_pos_above_top, "Primary 5")); |
|
1987 QVERIFY(checkLabelAt(mWindow, expected_label_pos_above_bottom, "Secondary 5")); |
|
1988 |
|
1989 mMediawall->setDescriptionPosition(HgMediawall::PositionNone); |
|
1990 QVERIFY(mMediawall->titlePosition() == HgMediawall::PositionAboveImage); |
|
1991 QVERIFY(mMediawall->descriptionPosition() == HgMediawall::PositionNone); |
|
1992 mMediawall->setCurrentIndex(model.index(6, 0)); |
|
1993 QTest::qWait(1000); |
|
1994 QVERIFY(checkLabelAt(mWindow, expected_label_pos_above_alone, "Primary 6")); |
|
1995 |
|
1996 mMediawall->setTitlePosition(HgMediawall::PositionBelowImage); |
|
1997 QVERIFY(mMediawall->titlePosition() == HgMediawall::PositionBelowImage); |
|
1998 QVERIFY(mMediawall->descriptionPosition() == HgMediawall::PositionNone); |
|
1999 mMediawall->setCurrentIndex(model.index(7, 0)); |
|
2000 QTest::qWait(1000); |
|
2001 QVERIFY(checkLabelAt(mWindow, expected_label_pos_below_alone, "Primary 7")); |
|
2002 |
|
2003 mMediawall->setDescriptionPosition(HgMediawall::PositionAboveImage); |
|
2004 QVERIFY(mMediawall->titlePosition() == HgMediawall::PositionBelowImage); |
|
2005 QVERIFY(mMediawall->descriptionPosition() == HgMediawall::PositionAboveImage); |
|
2006 mMediawall->setCurrentIndex(model.index(8, 0)); |
|
2007 QTest::qWait(1000); |
|
2008 QVERIFY(checkLabelAt(mWindow, expected_label_pos_above_alone, "Secondary 8")); |
|
2009 QVERIFY(checkLabelAt(mWindow, expected_label_pos_below_alone, "Primary 8")); |
|
2010 |
|
2011 mMediawall->setDescriptionPosition(HgMediawall::PositionBelowImage); |
|
2012 QVERIFY(mMediawall->titlePosition() == HgMediawall::PositionBelowImage); |
|
2013 QVERIFY(mMediawall->descriptionPosition() == HgMediawall::PositionBelowImage); |
|
2014 mMediawall->setCurrentIndex(model.index(9, 0)); |
|
2015 QTest::qWait(1000); |
|
2016 QVERIFY(checkLabelAt(mWindow, expected_label_pos_below_top, "Primary 9")); |
|
2017 QVERIFY(checkLabelAt(mWindow, expected_label_pos_below_bottom, "Secondary 9")); |
|
2018 |
|
2019 QTest::qWait(2000); |
|
2020 |
|
2021 delete mWindow; |
|
2022 mWindow = 0; |
|
2023 } |
|
2024 |
|
2025 void TestGanesWidgets::test_labelFontSpecsCoverFlow() |
|
2026 { |
1960 { |
2027 mWindow = new HbMainWindow; |
1961 mWindow = new HbMainWindow; |
2028 mMediawall = new HgMediawall(); |
1962 mMediawall = new HgMediawall(); |
2029 |
1963 |
2030 TestModel model; |
1964 TestModel model; |
2031 model.generateItems(50); |
1965 model.generateItems(50); |
2032 mWindow->addView(mMediawall); |
1966 mWindow->addView(mMediawall); |
2033 mMediawall->setModel(&model); |
1967 mMediawall->setModel(&model); |
2034 mWindow->show(); |
1968 mWindow->show(); |
2035 |
1969 |
2036 mMediawall->setTitleFontSpec(HbFontSpec(HbFontSpec::Primary)); |
|
2037 QVERIFY(mMediawall->titleFontSpec() == HbFontSpec(HbFontSpec::Primary)); |
|
2038 |
|
2039 mMediawall->setDescriptionFontSpec(HbFontSpec(HbFontSpec::Secondary)); |
|
2040 QVERIFY(mMediawall->descriptionFontSpec() == HbFontSpec(HbFontSpec::Secondary)); |
|
2041 |
|
2042 mMediawall->setTitleFontSpec(HbFontSpec(HbFontSpec::Title)); |
|
2043 QVERIFY(mMediawall->titleFontSpec() == HbFontSpec(HbFontSpec::Title)); |
|
2044 |
|
2045 mMediawall->setDescriptionFontSpec(HbFontSpec(HbFontSpec::PrimarySmall)); |
|
2046 QVERIFY(mMediawall->descriptionFontSpec() == HbFontSpec(HbFontSpec::PrimarySmall)); |
|
2047 |
|
2048 QTest::qWait(2000); |
|
2049 |
|
2050 delete mWindow; |
|
2051 mWindow = 0; |
|
2052 } |
|
2053 |
|
2054 void TestGanesWidgets::test_resetModelCoverFlow() |
|
2055 { |
|
2056 mWindow = new HbMainWindow; |
|
2057 mMediawall = new HgMediawall(); |
|
2058 |
|
2059 TestModel model; |
|
2060 model.generateItems(50); |
|
2061 mWindow->addView(mMediawall); |
|
2062 mMediawall->setModel(&model); |
|
2063 mWindow->show(); |
|
2064 |
|
2065 // Reset with same item count |
1970 // Reset with same item count |
2066 model.reset(50); |
1971 model.reset(50); |
2067 QTest::qWait(2000); |
1972 QTest::qWait(2000); |
2068 |
1973 |
2069 // Reset with smaller item count |
1974 // Reset with smaller item count |