Update expectations according to build bot status.
[chromium-blink-merge.git] / app / gtk_dnd_util_unittest.cc
blob1de8991829628aec2246510654b3ab2e09f32d38
1 // Copyright (c) 2010 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.
5 #include <string>
7 #include "app/gtk_dnd_util.h"
8 #include "base/pickle.h"
9 #include "base/scoped_ptr.h"
10 #include "base/utf_string_conversions.h"
11 #include "googleurl/src/gurl.h"
12 #include "testing/gtest/include/gtest/gtest.h"
14 TEST(GtkDndUtilTest, ExtractNamedURLValid) {
15 const std::string kTitle = "title";
16 const std::string kUrl = "http://www.foobar.com/";
17 Pickle pickle;
18 pickle.WriteString(kTitle);
19 pickle.WriteString(kUrl);
21 GtkSelectionData data;
22 scoped_array<guchar> test_data(new guchar[pickle.size()]);
23 memcpy(test_data.get(), pickle.data(), pickle.size());
24 data.data = test_data.get();
25 data.length = pickle.size();
27 GURL url;
28 string16 title;
29 ASSERT_EQ(true, gtk_dnd_util::ExtractNamedURL(&data, &url, &title));
30 EXPECT_EQ(UTF8ToUTF16(kTitle), title);
31 EXPECT_EQ(GURL(kUrl), url);
34 TEST(GtkDndUtilTest, ExtractNamedURLInvalidURL) {
35 const std::string kTitle = "title";
36 const std::string kBadUrl = "foobar";
37 Pickle pickle;
38 pickle.WriteString(kTitle);
39 pickle.WriteString(kBadUrl);
41 GtkSelectionData data;
42 scoped_array<guchar> test_data(new guchar[pickle.size()]);
43 memcpy(test_data.get(), pickle.data(), pickle.size());
44 data.data = test_data.get();
45 data.length = pickle.size();
47 GURL url;
48 string16 title;
49 EXPECT_EQ(false, gtk_dnd_util::ExtractNamedURL(&data, &url, &title));
52 TEST(GtkDndUtilTest, ExtractNamedURLInvalidInput) {
53 GURL url;
54 string16 title;
55 GtkSelectionData data;
56 data.data = NULL;
57 data.length = 0;
59 EXPECT_EQ(false, gtk_dnd_util::ExtractNamedURL(&data, &url, &title));
61 guchar empty_data[] = "";
62 data.data = empty_data;
63 data.length = 0;
65 EXPECT_EQ(false, gtk_dnd_util::ExtractNamedURL(&data, &url, &title));
67 const std::string kTitle = "title";
68 Pickle pickle;
69 pickle.WriteString(kTitle);
71 scoped_array<guchar> test_data(new guchar[pickle.size()]);
72 memcpy(test_data.get(), pickle.data(), pickle.size());
73 data.data = test_data.get();
74 data.length = pickle.size();
76 EXPECT_EQ(false, gtk_dnd_util::ExtractNamedURL(&data, &url, &title));