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
3 // found in the LICENSE file.
4
5 #include "ui/base/dragdrop/os_exchange_data_provider_aurax11.h"
6
7 // Clean up X11 header polution
8 #undef None
9 #undef Bool
10
11 #include "base/message_loop/message_loop.h"
12 #include "base/strings/string16.h"
13 #include "base/strings/utf_string_conversions.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "url/gurl.h"
16
17 const char kGoogleTitle[] = "Google";
18 const char kGoogleURL[] = "http://www.google.com/";
19
TEST(OSExchangeDataProviderAuraX11Test,MozillaURL)20 TEST(OSExchangeDataProviderAuraX11Test, MozillaURL) {
21 base::MessageLoopForUI message_loop;
22 ui::OSExchangeDataProviderAuraX11 provider;
23
24 // Check that we can get titled entries.
25 provider.SetURL(GURL(kGoogleURL), ASCIIToUTF16(kGoogleTitle));
26 {
27 GURL out_gurl;
28 base::string16 out_str;
29 EXPECT_TRUE(provider.GetURLAndTitle(
30 OSExchangeData::DO_NOT_CONVERT_FILENAMES, &out_gurl, &out_str));
31 EXPECT_EQ(ASCIIToUTF16(kGoogleTitle), out_str);
32 EXPECT_EQ(kGoogleURL, out_gurl.spec());
33 }
34
35 // Check that we can get non-titled entries.
36 provider.SetURL(GURL(kGoogleURL), string16());
37 {
38 GURL out_gurl;
39 base::string16 out_str;
40 EXPECT_TRUE(provider.GetURLAndTitle(
41 OSExchangeData::DO_NOT_CONVERT_FILENAMES, &out_gurl, &out_str));
42 EXPECT_EQ(string16(), out_str);
43 EXPECT_EQ(kGoogleURL, out_gurl.spec());
44 }
45 }
46