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

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

Issue 368973003: MacViews: Partially implement OSExchangeDataProviderMac. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: lastObject -> objectAtIndex Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « ui/base/dragdrop/os_exchange_data_provider_mac.mm ('k') | ui/ui_unittests.gyp » ('j') | 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/message_loop/message_loop.h" 5 #include "base/message_loop/message_loop.h"
6 #include "base/pickle.h" 6 #include "base/pickle.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "testing/platform_test.h" 9 #include "testing/platform_test.h"
10 #include "ui/base/dragdrop/os_exchange_data.h" 10 #include "ui/base/dragdrop/os_exchange_data.h"
11 #include "ui/events/platform/platform_event_source.h" 11 #include "ui/events/platform/platform_event_source.h"
12 #include "url/gurl.h" 12 #include "url/gurl.h"
13 13
14 namespace ui { 14 namespace ui {
15 15
16 class OSExchangeDataTest : public PlatformTest { 16 class OSExchangeDataTest : public PlatformTest {
17 public: 17 public:
18 OSExchangeDataTest() 18 OSExchangeDataTest()
19 : event_source_(ui::PlatformEventSource::CreateDefault()) {} 19 : event_source_(ui::PlatformEventSource::CreateDefault()) {}
20 20
21 private: 21 private:
22 base::MessageLoopForUI message_loop_; 22 base::MessageLoopForUI message_loop_;
23 scoped_ptr<PlatformEventSource> event_source_; 23 scoped_ptr<PlatformEventSource> event_source_;
24 }; 24 };
25 25
26 TEST_F(OSExchangeDataTest, StringDataGetAndSet) { 26 TEST_F(OSExchangeDataTest, StringDataGetAndSet) {
27 OSExchangeData data; 27 OSExchangeData data;
28 base::string16 input = base::ASCIIToUTF16("I can has cheezburger?"); 28 base::string16 input = base::ASCIIToUTF16("I can has cheezburger?");
29 EXPECT_FALSE(data.HasString());
29 data.SetString(input); 30 data.SetString(input);
31 EXPECT_TRUE(data.HasString());
30 32
31 OSExchangeData data2(data.provider().Clone()); 33 OSExchangeData data2(data.provider().Clone());
32 base::string16 output; 34 base::string16 output;
35 EXPECT_TRUE(data2.HasString());
33 EXPECT_TRUE(data2.GetString(&output)); 36 EXPECT_TRUE(data2.GetString(&output));
34 EXPECT_EQ(input, output); 37 EXPECT_EQ(input, output);
35 std::string url_spec = "http://www.goats.com/"; 38 std::string url_spec = "http://www.goats.com/";
36 GURL url(url_spec); 39 GURL url(url_spec);
37 base::string16 title; 40 base::string16 title;
38 EXPECT_FALSE( 41 EXPECT_FALSE(
39 data2.GetURLAndTitle(OSExchangeData::CONVERT_FILENAMES, &url, &title)); 42 data2.GetURLAndTitle(OSExchangeData::CONVERT_FILENAMES, &url, &title));
40 // No URLs in |data|, so url should be untouched. 43 // No URLs in |data|, so url should be untouched.
41 EXPECT_EQ(url_spec, url.spec()); 44 EXPECT_EQ(url_spec, url.spec());
42 } 45 }
43 46
44 TEST_F(OSExchangeDataTest, TestURLExchangeFormats) { 47 TEST_F(OSExchangeDataTest, TestURLExchangeFormats) {
45 OSExchangeData data; 48 OSExchangeData data;
46 std::string url_spec = "http://www.google.com/"; 49 std::string url_spec = "http://www.google.com/";
47 GURL url(url_spec); 50 GURL url(url_spec);
48 base::string16 url_title = base::ASCIIToUTF16("www.google.com"); 51 base::string16 url_title = base::ASCIIToUTF16("www.google.com");
52 EXPECT_FALSE(data.HasURL(OSExchangeData::DO_NOT_CONVERT_FILENAMES));
49 data.SetURL(url, url_title); 53 data.SetURL(url, url_title);
50 base::string16 output; 54 EXPECT_TRUE(data.HasURL(OSExchangeData::DO_NOT_CONVERT_FILENAMES));
51 55
52 OSExchangeData data2(data.provider().Clone()); 56 OSExchangeData data2(data.provider().Clone());
53 57
54 // URL spec and title should match 58 // URL spec and title should match
55 GURL output_url; 59 GURL output_url;
56 base::string16 output_title; 60 base::string16 output_title;
61 EXPECT_TRUE(data2.HasURL(OSExchangeData::DO_NOT_CONVERT_FILENAMES));
57 EXPECT_TRUE(data2.GetURLAndTitle( 62 EXPECT_TRUE(data2.GetURLAndTitle(
58 OSExchangeData::CONVERT_FILENAMES, &output_url, &output_title)); 63 OSExchangeData::DO_NOT_CONVERT_FILENAMES, &output_url, &output_title));
59 EXPECT_EQ(url_spec, output_url.spec()); 64 EXPECT_EQ(url_spec, output_url.spec());
60 EXPECT_EQ(url_title, output_title); 65 EXPECT_EQ(url_title, output_title);
61 base::string16 output_string; 66 base::string16 output_string;
62 67
63 // URL should be the raw text response 68 // URL should be the raw text response
64 EXPECT_TRUE(data2.GetString(&output_string)); 69 EXPECT_TRUE(data2.GetString(&output_string));
65 EXPECT_EQ(url_spec, base::UTF16ToUTF8(output_string)); 70 EXPECT_EQ(url_spec, base::UTF16ToUTF8(output_string));
66 } 71 }
67 72
68 TEST_F(OSExchangeDataTest, TestPickledData) { 73 TEST_F(OSExchangeDataTest, TestPickledData) {
(...skipping 30 matching lines...) Expand all
99 data.SetHtml(html, url); 104 data.SetHtml(html, url);
100 105
101 OSExchangeData copy(data.provider().Clone()); 106 OSExchangeData copy(data.provider().Clone());
102 base::string16 read_html; 107 base::string16 read_html;
103 EXPECT_TRUE(copy.GetHtml(&read_html, &url)); 108 EXPECT_TRUE(copy.GetHtml(&read_html, &url));
104 EXPECT_EQ(html, read_html); 109 EXPECT_EQ(html, read_html);
105 } 110 }
106 #endif 111 #endif
107 112
108 } // namespace ui 113 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/dragdrop/os_exchange_data_provider_mac.mm ('k') | ui/ui_unittests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698