Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / ui / base / clipboard / clipboard_unittest.cc
index 6df2399..72c07cf 100644 (file)
 #include "base/android/jni_string.h"
 #endif
 
+#if defined(USE_AURA)
+#include "ui/events/platform/platform_event_source.h"
+#endif
+
 using base::ASCIIToUTF16;
 using base::UTF8ToUTF16;
 using base::UTF16ToUTF8;
@@ -40,6 +44,12 @@ namespace ui {
 
 class ClipboardTest : public PlatformTest {
  public:
+#if defined(USE_AURA)
+  ClipboardTest() : event_source_(ui::PlatformEventSource::CreateDefault()) {}
+#else
+  ClipboardTest() {}
+#endif
+
   static void WriteObjectsToClipboard(ui::Clipboard* clipboard,
                                       const Clipboard::ObjectMap& objects) {
     clipboard->WriteObjects(ui::CLIPBOARD_TYPE_COPY_PASTE, objects);
@@ -54,6 +64,9 @@ class ClipboardTest : public PlatformTest {
 
  private:
   base::MessageLoopForUI message_loop_;
+#if defined(USE_AURA)
+  scoped_ptr<PlatformEventSource> event_source_;
+#endif
   Clipboard clipboard_;
 };
 
@@ -146,7 +159,9 @@ TEST_F(ClipboardTest, RTFTest) {
   EXPECT_EQ(rtf, result);
 }
 
-#if defined(TOOLKIT_GTK)
+// TODO(dnicoara) Enable test once Ozone implements clipboard support:
+// crbug.com/361707
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(USE_OZONE)
 TEST_F(ClipboardTest, MultipleBufferTest) {
   base::string16 text(ASCIIToUTF16("Standard")), text_result;
   base::string16 markup(ASCIIToUTF16("<string>Selection</string>"));
@@ -241,27 +256,6 @@ TEST_F(ClipboardTest, UniodeHTMLTest) {
 }
 #endif  // defined(OS_WIN)
 
-#if defined(TOOLKIT_GTK)
-// Regression test for crbug.com/56298 (pasting empty HTML crashes Linux).
-TEST_F(ClipboardTest, EmptyHTMLTest) {
-  // ScopedClipboardWriter doesn't let us write empty data to the clipboard.
-  clipboard().clipboard_data_ = new Clipboard::TargetMap();
-  // The 1 is so the compiler doesn't warn about allocating an empty array.
-  char* empty = new char[1];
-  clipboard().InsertMapping("text/html", empty, 0U);
-  clipboard().SetGtkClipboard(CLIPBOARD_TYPE_COPY_PASTE);
-
-  EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetHtmlFormatType(),
-                                            CLIPBOARD_TYPE_COPY_PASTE));
-  base::string16 markup_result;
-  std::string url_result;
-  uint32 ignored;
-  clipboard().ReadHTML(CLIPBOARD_TYPE_COPY_PASTE, &markup_result, &url_result,
-                       &ignored, &ignored);
-  EXPECT_PRED2(MarkupMatches, base::string16(), markup_result);
-}
-#endif
-
 // TODO(estade): Port the following test (decide what target we use for urls)
 #if !defined(OS_POSIX) || defined(OS_MACOSX)
 TEST_F(ClipboardTest, BookmarkTest) {
@@ -401,19 +395,8 @@ static void TestBitmapWrite(Clipboard* clipboard,
     for (int i = 0; i < image.width(); ++i) {
       int offset = i + j * image.width();
       uint32 pixel = SkPreMultiplyColor(bitmap_data[offset]);
-#if defined(TOOLKIT_GTK)
-      // Non-Aura GTK doesn't support alpha transparency. Instead, the alpha
-      // channel is always set to 0xFF - see http://crbug.com/154573.
-      // However, since we premultiplied above, we must also premultiply here
-      // before unpremultiplying and setting alpha to 0xFF; otherwise, the
-      // results will not match GTK's.
-      EXPECT_EQ(
-          SkUnPreMultiply::PMColorToColor(pixel) | 0xFF000000, row_address[i])
-          << "i = " << i << ", j = " << j;
-#else
       EXPECT_EQ(pixel, row_address[i])
           << "i = " << i << ", j = " << j;
-#endif  // defined(TOOLKIT_GTK)
     }
   }
 }