// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "public/platform/WebDragData.h"

#include "core/clipboard/DataObject.h"
#include "public/platform/WebVector.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace blink {

TEST(WebDragDataTest, items) {
  DataObject* dataObject = DataObject::create();

  // Native file.
  dataObject->add(File::create("/native/path"));

  // Blob file.
  const RefPtr<BlobDataHandle> blobDataHandle = BlobDataHandle::create();
  dataObject->add(File::create("name", 0.0, blobDataHandle));

  // User visible snapshot file.
  {
    FileMetadata metadata;
    metadata.platformPath = "/native/visible/snapshot";
    dataObject->add(
        File::createForFileSystemFile("name", metadata, File::IsUserVisible));
  }

  // Not user visible snapshot file.
  {
    FileMetadata metadata;
    metadata.platformPath = "/native/not-visible/snapshot";
    dataObject->add(File::createForFileSystemFile("name", metadata,
                                                  File::IsNotUserVisible));
  }

  // User visible file system URL file.
  {
    FileMetadata metadata;
    metadata.length = 1234;
    KURL url(
        ParsedURLStringTag(),
        "filesystem:http://example.com/isolated/hash/visible-non-native-file");
    dataObject->add(
        File::createForFileSystemFile(url, metadata, File::IsUserVisible));
  }

  // Not user visible file system URL file.
  {
    FileMetadata metadata;
    metadata.length = 1234;
    KURL url(ParsedURLStringTag(),
             "filesystem:http://example.com/isolated/hash/"
             "not-visible-non-native-file");
    dataObject->add(
        File::createForFileSystemFile(url, metadata, File::IsNotUserVisible));
  }

  WebDragData data = dataObject->toWebDragData();
  WebVector<WebDragData::Item> items = data.items();
  ASSERT_EQ(6u, items.size());

  EXPECT_EQ(WebDragData::Item::StorageTypeFilename, items[0].storageType);
  EXPECT_EQ("/native/path", items[0].filenameData);
  EXPECT_EQ("path", items[0].displayNameData);

  EXPECT_EQ(WebDragData::Item::StorageTypeString, items[1].storageType);
  EXPECT_EQ("text/plain", items[1].stringType);
  EXPECT_EQ("name", items[1].stringData);

  EXPECT_EQ(WebDragData::Item::StorageTypeFilename, items[2].storageType);
  EXPECT_EQ("/native/visible/snapshot", items[2].filenameData);
  EXPECT_EQ("name", items[2].displayNameData);

  EXPECT_EQ(WebDragData::Item::StorageTypeFilename, items[3].storageType);
  EXPECT_EQ("/native/not-visible/snapshot", items[3].filenameData);
  EXPECT_EQ("name", items[3].displayNameData);

  EXPECT_EQ(WebDragData::Item::StorageTypeFileSystemFile, items[4].storageType);
  EXPECT_EQ(
      "filesystem:http://example.com/isolated/hash/visible-non-native-file",
      items[4].fileSystemURL);
  EXPECT_EQ(1234, items[4].fileSystemFileSize);

  EXPECT_EQ(WebDragData::Item::StorageTypeFileSystemFile, items[5].storageType);
  EXPECT_EQ(
      "filesystem:http://example.com/isolated/hash/not-visible-non-native-file",
      items[5].fileSystemURL);
  EXPECT_EQ(1234, items[5].fileSystemFileSize);
}

}  // namespace blink
