forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fill out more data types on OSExchangeDataProviderAuraX11.
This also makes OSExchangeDataProvider unit tests that are cross platform actually cross platform. BUG=130806 Review URL: https://chromiumcodereview.appspot.com/17776002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@208985 0039d316-1c4b-4281-b951-d872f2087c98
- Loading branch information
erg@chromium.org
committed
Jun 27, 2013
1 parent
f8b23b4
commit b17e31d
Showing
10 changed files
with
205 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// Copyright 2013 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "base/message_loop.h" | ||
#include "base/pickle.h" | ||
#include "base/strings/utf_string_conversions.h" | ||
#include "googleurl/src/gurl.h" | ||
#include "testing/gtest/include/gtest/gtest.h" | ||
#include "testing/platform_test.h" | ||
#include "ui/base/dragdrop/os_exchange_data.h" | ||
|
||
namespace ui { | ||
|
||
class OSExchangeDataTest : public PlatformTest { | ||
private: | ||
base::MessageLoopForUI message_loop_; | ||
}; | ||
|
||
TEST_F(OSExchangeDataTest, StringDataGetAndSet) { | ||
OSExchangeData data; | ||
string16 input = ASCIIToUTF16("I can has cheezburger?"); | ||
data.SetString(input); | ||
|
||
OSExchangeData data2(data.provider().Clone()); | ||
string16 output; | ||
EXPECT_TRUE(data2.GetString(&output)); | ||
EXPECT_EQ(input, output); | ||
std::string url_spec = "http://www.goats.com/"; | ||
GURL url(url_spec); | ||
string16 title; | ||
EXPECT_FALSE(data2.GetURLAndTitle(&url, &title)); | ||
// No URLs in |data|, so url should be untouched. | ||
EXPECT_EQ(url_spec, url.spec()); | ||
} | ||
|
||
TEST_F(OSExchangeDataTest, TestURLExchangeFormats) { | ||
OSExchangeData data; | ||
std::string url_spec = "http://www.google.com/"; | ||
GURL url(url_spec); | ||
string16 url_title = ASCIIToUTF16("www.google.com"); | ||
data.SetURL(url, url_title); | ||
string16 output; | ||
|
||
OSExchangeData data2(data.provider().Clone()); | ||
|
||
// URL spec and title should match | ||
GURL output_url; | ||
string16 output_title; | ||
EXPECT_TRUE(data2.GetURLAndTitle(&output_url, &output_title)); | ||
EXPECT_EQ(url_spec, output_url.spec()); | ||
EXPECT_EQ(url_title, output_title); | ||
string16 output_string; | ||
|
||
// URL should be the raw text response | ||
EXPECT_TRUE(data2.GetString(&output_string)); | ||
EXPECT_EQ(url_spec, UTF16ToUTF8(output_string)); | ||
} | ||
|
||
TEST_F(OSExchangeDataTest, TestPickledData) { | ||
const OSExchangeData::CustomFormat kTestFormat = | ||
ui::Clipboard::GetFormatType("application/vnd.chromium.test"); | ||
|
||
Pickle saved_pickle; | ||
saved_pickle.WriteInt(1); | ||
saved_pickle.WriteInt(2); | ||
OSExchangeData data; | ||
data.SetPickledData(kTestFormat, saved_pickle); | ||
|
||
OSExchangeData copy(data.provider().Clone()); | ||
EXPECT_TRUE(copy.HasCustomFormat(kTestFormat)); | ||
|
||
Pickle restored_pickle; | ||
EXPECT_TRUE(copy.GetPickledData(kTestFormat, &restored_pickle)); | ||
PickleIterator iterator(restored_pickle); | ||
int value; | ||
EXPECT_TRUE(restored_pickle.ReadInt(&iterator, &value)); | ||
EXPECT_EQ(1, value); | ||
EXPECT_TRUE(restored_pickle.ReadInt(&iterator, &value)); | ||
EXPECT_EQ(2, value); | ||
} | ||
|
||
TEST_F(OSExchangeDataTest, TestHTML) { | ||
OSExchangeData data; | ||
GURL url("http://www.google.com/"); | ||
string16 html = ASCIIToUTF16( | ||
"<HTML>\n<BODY>\n" | ||
"<b>bold.</b> <i><b>This is bold italic.</b></i>\n" | ||
"</BODY>\n</HTML>"); | ||
data.SetHtml(html, url); | ||
|
||
OSExchangeData copy(data.provider().Clone()); | ||
string16 read_html; | ||
EXPECT_TRUE(copy.GetHtml(&read_html, &url)); | ||
EXPECT_EQ(html, read_html); | ||
} | ||
|
||
} // namespace ui |
Oops, something went wrong.