| OLD | NEW | 
|    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" | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
|   22   string16 input = ASCIIToUTF16("I can has cheezburger?"); |   22   string16 input = ASCIIToUTF16("I can has cheezburger?"); | 
|   23   data.SetString(input); |   23   data.SetString(input); | 
|   24  |   24  | 
|   25   OSExchangeData data2(data.provider().Clone()); |   25   OSExchangeData data2(data.provider().Clone()); | 
|   26   string16 output; |   26   string16 output; | 
|   27   EXPECT_TRUE(data2.GetString(&output)); |   27   EXPECT_TRUE(data2.GetString(&output)); | 
|   28   EXPECT_EQ(input, output); |   28   EXPECT_EQ(input, output); | 
|   29   std::string url_spec = "http://www.goats.com/"; |   29   std::string url_spec = "http://www.goats.com/"; | 
|   30   GURL url(url_spec); |   30   GURL url(url_spec); | 
|   31   string16 title; |   31   string16 title; | 
|   32   EXPECT_FALSE(data2.GetURLAndTitle(&url, &title)); |   32   EXPECT_FALSE( | 
 |   33       data2.GetURLAndTitle(OSExchangeData::CONVERT_FILENAMES, &url, &title)); | 
|   33   // No URLs in |data|, so url should be untouched. |   34   // No URLs in |data|, so url should be untouched. | 
|   34   EXPECT_EQ(url_spec, url.spec()); |   35   EXPECT_EQ(url_spec, url.spec()); | 
|   35 } |   36 } | 
|   36  |   37  | 
|   37 TEST_F(OSExchangeDataTest, TestURLExchangeFormats) { |   38 TEST_F(OSExchangeDataTest, TestURLExchangeFormats) { | 
|   38   OSExchangeData data; |   39   OSExchangeData data; | 
|   39   std::string url_spec = "http://www.google.com/"; |   40   std::string url_spec = "http://www.google.com/"; | 
|   40   GURL url(url_spec); |   41   GURL url(url_spec); | 
|   41   string16 url_title = ASCIIToUTF16("www.google.com"); |   42   string16 url_title = ASCIIToUTF16("www.google.com"); | 
|   42   data.SetURL(url, url_title); |   43   data.SetURL(url, url_title); | 
|   43   string16 output; |   44   string16 output; | 
|   44  |   45  | 
|   45   OSExchangeData data2(data.provider().Clone()); |   46   OSExchangeData data2(data.provider().Clone()); | 
|   46  |   47  | 
|   47   // URL spec and title should match |   48   // URL spec and title should match | 
|   48   GURL output_url; |   49   GURL output_url; | 
|   49   string16 output_title; |   50   string16 output_title; | 
|   50   EXPECT_TRUE(data2.GetURLAndTitle(&output_url, &output_title)); |   51   EXPECT_TRUE(data2.GetURLAndTitle( | 
 |   52       OSExchangeData::CONVERT_FILENAMES, &output_url, &output_title)); | 
|   51   EXPECT_EQ(url_spec, output_url.spec()); |   53   EXPECT_EQ(url_spec, output_url.spec()); | 
|   52   EXPECT_EQ(url_title, output_title); |   54   EXPECT_EQ(url_title, output_title); | 
|   53   string16 output_string; |   55   string16 output_string; | 
|   54  |   56  | 
|   55   // URL should be the raw text response |   57   // URL should be the raw text response | 
|   56   EXPECT_TRUE(data2.GetString(&output_string)); |   58   EXPECT_TRUE(data2.GetString(&output_string)); | 
|   57   EXPECT_EQ(url_spec, UTF16ToUTF8(output_string)); |   59   EXPECT_EQ(url_spec, UTF16ToUTF8(output_string)); | 
|   58 } |   60 } | 
|   59  |   61  | 
|   60 TEST_F(OSExchangeDataTest, TestPickledData) { |   62 TEST_F(OSExchangeDataTest, TestPickledData) { | 
| (...skipping 28 matching lines...) Expand all  Loading... | 
|   89       "</BODY>\n</HTML>"); |   91       "</BODY>\n</HTML>"); | 
|   90   data.SetHtml(html, url); |   92   data.SetHtml(html, url); | 
|   91  |   93  | 
|   92   OSExchangeData copy(data.provider().Clone()); |   94   OSExchangeData copy(data.provider().Clone()); | 
|   93   string16 read_html; |   95   string16 read_html; | 
|   94   EXPECT_TRUE(copy.GetHtml(&read_html, &url)); |   96   EXPECT_TRUE(copy.GetHtml(&read_html, &url)); | 
|   95   EXPECT_EQ(html, read_html); |   97   EXPECT_EQ(html, read_html); | 
|   96 } |   98 } | 
|   97  |   99  | 
|   98 }  // namespace ui |  100 }  // namespace ui | 
| OLD | NEW |