+
+
+void EllipsizationTestCase::EnoughSpace()
+{
+ // No ellipsization should occur if there's plenty of space.
+
+ wxMemoryDC dc;
+
+ CPPUNIT_ASSERT_EQUAL("some label",
+ wxControl::Ellipsize("some label", dc, wxELLIPSIZE_START, 200));
+ CPPUNIT_ASSERT_EQUAL("some label",
+ wxControl::Ellipsize("some label", dc, wxELLIPSIZE_MIDDLE, 200));
+ CPPUNIT_ASSERT_EQUAL("some label",
+ wxControl::Ellipsize("some label", dc, wxELLIPSIZE_END, 200));
+}
+
+
+void EllipsizationTestCase::VeryLittleSpace()
+{
+ // If there's not enough space, the shortened label should still contain "..." and one character
+
+ wxMemoryDC dc;
+
+ CPPUNIT_ASSERT_EQUAL("...l",
+ wxControl::Ellipsize("some label", dc, wxELLIPSIZE_START, 5));
+ CPPUNIT_ASSERT_EQUAL("s...",
+ wxControl::Ellipsize("some label", dc, wxELLIPSIZE_MIDDLE, 5));
+ CPPUNIT_ASSERT_EQUAL("s...",
+ wxControl::Ellipsize("some label1", dc, wxELLIPSIZE_MIDDLE, 5));
+ CPPUNIT_ASSERT_EQUAL("s...",
+ wxControl::Ellipsize("some label", dc, wxELLIPSIZE_END, 5));
+}
+
+
+void EllipsizationTestCase::HasThreeDots()
+{
+ wxMemoryDC dc;
+
+ CPPUNIT_ASSERT( wxControl::Ellipsize("some longer text", dc, wxELLIPSIZE_START, 80).StartsWith("...") );
+ CPPUNIT_ASSERT( !wxControl::Ellipsize("some longer text", dc, wxELLIPSIZE_START, 80).EndsWith("...") );
+
+ CPPUNIT_ASSERT( wxControl::Ellipsize("some longer text", dc, wxELLIPSIZE_END, 80).EndsWith("...") );
+
+ CPPUNIT_ASSERT( wxControl::Ellipsize("some longer text", dc, wxELLIPSIZE_MIDDLE, 80).Contains("...") );
+ CPPUNIT_ASSERT( !wxControl::Ellipsize("some longer text", dc, wxELLIPSIZE_MIDDLE, 80).StartsWith("...") );
+ CPPUNIT_ASSERT( !wxControl::Ellipsize("some longer text", dc, wxELLIPSIZE_MIDDLE, 80).EndsWith("...") );
+}