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

Side by Side Diff: ui/base/dragdrop/os_exchange_data_unittest.cc

Issue 542203004: MacViews: Get OSExchangeDataTest to pass (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 unified diff | Download patch
« no previous file with comments | « ui/base/dragdrop/os_exchange_data_provider_mac.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/files/file_util.h" 5 #include "base/files/file_util.h"
6 #include "base/message_loop/message_loop.h" 6 #include "base/message_loop/message_loop.h"
7 #include "base/pickle.h" 7 #include "base/pickle.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "net/base/filename_util.h" 9 #include "net/base/filename_util.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 TEST_F(OSExchangeDataTest, TestFileToURLConversion) { 97 TEST_F(OSExchangeDataTest, TestFileToURLConversion) {
98 OSExchangeData data; 98 OSExchangeData data;
99 EXPECT_FALSE(data.HasURL(OSExchangeData::DO_NOT_CONVERT_FILENAMES)); 99 EXPECT_FALSE(data.HasURL(OSExchangeData::DO_NOT_CONVERT_FILENAMES));
100 EXPECT_FALSE(data.HasURL(OSExchangeData::CONVERT_FILENAMES)); 100 EXPECT_FALSE(data.HasURL(OSExchangeData::CONVERT_FILENAMES));
101 EXPECT_FALSE(data.HasFile()); 101 EXPECT_FALSE(data.HasFile());
102 102
103 base::FilePath current_directory; 103 base::FilePath current_directory;
104 ASSERT_TRUE(base::GetCurrentDirectory(&current_directory)); 104 ASSERT_TRUE(base::GetCurrentDirectory(&current_directory));
105 105
106 data.SetFilename(current_directory); 106 data.SetFilename(current_directory);
107
107 { 108 {
108 EXPECT_FALSE(data.HasURL(OSExchangeData::DO_NOT_CONVERT_FILENAMES)); 109 EXPECT_FALSE(data.HasURL(OSExchangeData::DO_NOT_CONVERT_FILENAMES));
109 GURL actual_url; 110 GURL actual_url;
110 base::string16 actual_title; 111 base::string16 actual_title;
111 EXPECT_FALSE(data.GetURLAndTitle( 112 EXPECT_FALSE(data.GetURLAndTitle(
112 OSExchangeData::DO_NOT_CONVERT_FILENAMES, &actual_url, &actual_title)); 113 OSExchangeData::DO_NOT_CONVERT_FILENAMES, &actual_url, &actual_title));
113 EXPECT_EQ(GURL(), actual_url); 114 EXPECT_EQ(GURL(), actual_url);
114 EXPECT_EQ(base::string16(), actual_title); 115 EXPECT_EQ(base::string16(), actual_title);
115 } 116 }
117
116 { 118 {
117 // Filename to URL conversion is not implemented on ChromeOS or on non-X11 Linux 119 // Filename to URL conversion is not implemented on ChromeOS or on non-X11 Linux
118 // builds. 120 // builds.
119 #if defined(OS_CHROMEOS) || (defined(OS_LINUX) && !defined(USE_X11)) 121 #if defined(OS_CHROMEOS) || (defined(OS_LINUX) && !defined(USE_X11))
120 const bool expected_success = false; 122 const bool expected_success = false;
121 const GURL expected_url; 123 const GURL expected_url;
122 #else 124 #else
123 const bool expected_success = true; 125 const bool expected_success = true;
124 const GURL expected_url(net::FilePathToFileURL(current_directory)); 126 const GURL expected_url(net::FilePathToFileURL(current_directory));
125 #endif 127 #endif
126 EXPECT_EQ(expected_success, data.HasURL(OSExchangeData::CONVERT_FILENAMES)); 128 EXPECT_EQ(expected_success, data.HasURL(OSExchangeData::CONVERT_FILENAMES));
127 GURL actual_url; 129 GURL actual_url;
128 base::string16 actual_title; 130 base::string16 actual_title;
129 EXPECT_EQ( 131 EXPECT_EQ(
130 expected_success, 132 expected_success,
131 data.GetURLAndTitle( 133 data.GetURLAndTitle(
132 OSExchangeData::CONVERT_FILENAMES, &actual_url, &actual_title)); 134 OSExchangeData::CONVERT_FILENAMES, &actual_url, &actual_title));
133 EXPECT_EQ(expected_url, actual_url); 135 // Some Mac OS versions return the URL in file://localhost form instead
136 // of file:///, so we compare the url's path not its absolute string.
137 EXPECT_EQ(expected_url.path(), actual_url.path());
134 EXPECT_EQ(base::string16(), actual_title); 138 EXPECT_EQ(base::string16(), actual_title);
135 } 139 }
136 EXPECT_TRUE(data.HasFile()); 140 EXPECT_TRUE(data.HasFile());
137 base::FilePath actual_path; 141 base::FilePath actual_path;
138 EXPECT_TRUE(data.GetFilename(&actual_path)); 142 EXPECT_TRUE(data.GetFilename(&actual_path));
139 EXPECT_EQ(current_directory, actual_path); 143 EXPECT_EQ(current_directory, actual_path);
140 } 144 }
141 145
142 TEST_F(OSExchangeDataTest, TestPickledData) { 146 TEST_F(OSExchangeDataTest, TestPickledData) {
143 const OSExchangeData::CustomFormat kTestFormat = 147 const OSExchangeData::CustomFormat kTestFormat =
(...skipping 29 matching lines...) Expand all
173 data.SetHtml(html, url); 177 data.SetHtml(html, url);
174 178
175 OSExchangeData copy(data.provider().Clone()); 179 OSExchangeData copy(data.provider().Clone());
176 base::string16 read_html; 180 base::string16 read_html;
177 EXPECT_TRUE(copy.GetHtml(&read_html, &url)); 181 EXPECT_TRUE(copy.GetHtml(&read_html, &url));
178 EXPECT_EQ(html, read_html); 182 EXPECT_EQ(html, read_html);
179 } 183 }
180 #endif 184 #endif
181 185
182 } // namespace ui 186 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/dragdrop/os_exchange_data_provider_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698