| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/pickle.h" | 5 #include "base/pickle.h" |
| 6 #include "chrome/browser/ui/views/extensions/browser_action_drag_data.h" | 6 #include "chrome/browser/ui/views/extensions/browser_action_drag_data.h" |
| 7 #include "chrome/test/base/testing_browser_process_test.h" | |
| 8 #include "chrome/test/base/testing_profile.h" | 7 #include "chrome/test/base/testing_profile.h" |
| 9 #include "googleurl/src/gurl.h" | 8 #include "googleurl/src/gurl.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "ui/base/dragdrop/os_exchange_data.h" | 10 #include "ui/base/dragdrop/os_exchange_data.h" |
| 12 #include "ui/base/dragdrop/os_exchange_data_provider_win.h" | 11 #include "ui/base/dragdrop/os_exchange_data_provider_win.h" |
| 13 | 12 |
| 14 namespace { | 13 namespace { |
| 15 | 14 |
| 16 ui::OSExchangeData::Provider* CloneProvider(const ui::OSExchangeData& data) { | 15 ui::OSExchangeData::Provider* CloneProvider(const ui::OSExchangeData& data) { |
| 17 return new ui::OSExchangeDataProviderWin( | 16 return new ui::OSExchangeDataProviderWin( |
| 18 ui::OSExchangeDataProviderWin::GetIDataObject(data)); | 17 ui::OSExchangeDataProviderWin::GetIDataObject(data)); |
| 19 } | 18 } |
| 20 | 19 |
| 21 } // namespace | 20 } // namespace |
| 22 | 21 |
| 23 typedef TestingBrowserProcessTest BrowserActionDragDataTest; | 22 typedef testing::Test BrowserActionDragDataTest; |
| 24 | 23 |
| 25 TEST_F(BrowserActionDragDataTest, ArbitraryFormat) { | 24 TEST_F(BrowserActionDragDataTest, ArbitraryFormat) { |
| 26 TestingProfile profile; | 25 TestingProfile profile; |
| 27 profile.SetID(L"id"); | 26 profile.SetID(L"id"); |
| 28 | 27 |
| 29 ui::OSExchangeData data; | 28 ui::OSExchangeData data; |
| 30 data.SetURL(GURL("http://www.google.com"), L"Title"); | 29 data.SetURL(GURL("http://www.google.com"), L"Title"); |
| 31 | 30 |
| 32 // We only support our format, so this should not succeed. | 31 // We only support our format, so this should not succeed. |
| 33 BrowserActionDragData drag_data; | 32 BrowserActionDragData drag_data; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 48 ui::OSExchangeData data; | 47 ui::OSExchangeData data; |
| 49 data.SetPickledData(BrowserActionDragData::GetBrowserActionCustomFormat(), | 48 data.SetPickledData(BrowserActionDragData::GetBrowserActionCustomFormat(), |
| 50 pickle); | 49 pickle); |
| 51 | 50 |
| 52 BrowserActionDragData drag_data; | 51 BrowserActionDragData drag_data; |
| 53 EXPECT_TRUE(drag_data.Read(ui::OSExchangeData(CloneProvider(data)))); | 52 EXPECT_TRUE(drag_data.Read(ui::OSExchangeData(CloneProvider(data)))); |
| 54 ASSERT_TRUE(drag_data.IsFromProfile(profile.GetOriginalProfile())); | 53 ASSERT_TRUE(drag_data.IsFromProfile(profile.GetOriginalProfile())); |
| 55 ASSERT_STREQ(extension_id.c_str(), drag_data.id().c_str()); | 54 ASSERT_STREQ(extension_id.c_str(), drag_data.id().c_str()); |
| 56 ASSERT_EQ(42, drag_data.index()); | 55 ASSERT_EQ(42, drag_data.index()); |
| 57 } | 56 } |
| OLD | NEW |