| Index: ui/base/dragdrop/os_exchange_data_provider_aurax11_unittest.cc
|
| diff --git a/ui/base/dragdrop/os_exchange_data_provider_aurax11_unittest.cc b/ui/base/dragdrop/os_exchange_data_provider_aurax11_unittest.cc
|
| index a09198d5cf74102883fc55aa6befedcf6a817d90..e3bf0e86569162d21d6ba3330683efa402b7b94f 100644
|
| --- a/ui/base/dragdrop/os_exchange_data_provider_aurax11_unittest.cc
|
| +++ b/ui/base/dragdrop/os_exchange_data_provider_aurax11_unittest.cc
|
| @@ -14,13 +14,33 @@
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| #include "url/gurl.h"
|
|
|
| +const char kFileURL[] = "file:///home/user/file.txt";
|
| +const char kFileName[] = "/home/user/file.txt";
|
| const char kGoogleTitle[] = "Google";
|
| const char kGoogleURL[] = "http://www.google.com/";
|
|
|
| -TEST(OSExchangeDataProviderAuraX11Test, MozillaURL) {
|
| +namespace ui {
|
| +
|
| +class OSExchangeDataProviderAuraX11Test : public testing::Test {
|
| + public:
|
| + OSExchangeDataProviderAuraX11Test() {}
|
| +
|
| + void AddURLList(const std::string& list_contents) {
|
| + std::string contents_copy = list_contents;
|
| + scoped_refptr<base::RefCountedMemory> mem(
|
| + base::RefCountedString::TakeString(&contents_copy));
|
| +
|
| + provider.format_map_.Insert(
|
| + provider.atom_cache_.GetAtom(ui::Clipboard::kMimeTypeURIList),
|
| + mem);
|
| + }
|
| +
|
| + protected:
|
| base::MessageLoopForUI message_loop;
|
| ui::OSExchangeDataProviderAuraX11 provider;
|
| +};
|
|
|
| +TEST_F(OSExchangeDataProviderAuraX11Test, MozillaURL) {
|
| // Check that we can get titled entries.
|
| provider.SetURL(GURL(kGoogleURL), base::ASCIIToUTF16(kGoogleTitle));
|
| {
|
| @@ -41,3 +61,39 @@ TEST(OSExchangeDataProviderAuraX11Test, MozillaURL) {
|
| EXPECT_EQ(kGoogleURL, out_gurl.spec());
|
| }
|
| }
|
| +
|
| +TEST_F(OSExchangeDataProviderAuraX11Test, FilesArentURLs) {
|
| + AddURLList(kFileURL);
|
| +
|
| + EXPECT_TRUE(provider.HasFile());
|
| + EXPECT_FALSE(provider.HasURL());
|
| +}
|
| +
|
| +TEST_F(OSExchangeDataProviderAuraX11Test, HTTPURLsArentFiles) {
|
| + AddURLList(kGoogleURL);
|
| +
|
| + EXPECT_FALSE(provider.HasFile());
|
| + EXPECT_TRUE(provider.HasURL());
|
| +}
|
| +
|
| +TEST_F(OSExchangeDataProviderAuraX11Test, URIListWithBoth) {
|
| + AddURLList("file:///home/user/file.txt\nhttp://www.google.com");
|
| +
|
| + EXPECT_TRUE(provider.HasFile());
|
| + EXPECT_TRUE(provider.HasURL());
|
| +
|
| + // We should only receive the file from GetFilenames().
|
| + std::vector<OSExchangeData::FileInfo> filenames;
|
| + EXPECT_TRUE(provider.GetFilenames(&filenames));
|
| + ASSERT_EQ(1u, filenames.size());
|
| + EXPECT_EQ(kFileName, filenames[0].path.value());
|
| +
|
| + // We should only receive the URL here.
|
| + GURL out_gurl;
|
| + base::string16 out_str;
|
| + EXPECT_TRUE(provider.GetURLAndTitle(&out_gurl, &out_str));
|
| + EXPECT_EQ(base::string16(), out_str);
|
| + EXPECT_EQ(kGoogleURL, out_gurl.spec());
|
| +}
|
| +
|
| +} // namespace ui
|
|
|