Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(535)

Unified Diff: ui/base/dragdrop/os_exchange_data_provider_aurax11_unittest.cc

Issue 129113004: linux_aura: Implement file drag and drop in content area. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/dragdrop/os_exchange_data_provider_aurax11.cc ('k') | ui/base/x/selection_utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « ui/base/dragdrop/os_exchange_data_provider_aurax11.cc ('k') | ui/base/x/selection_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698