| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ios/web/public/browser_state.h" | 5 #include "ios/web/public/browser_state.h" |
| 6 | 6 |
| 7 #include "base/supports_user_data.h" | 7 #include "base/supports_user_data.h" |
| 8 #include "ios/web/public/test/test_browser_state.h" | 8 #include "ios/web/public/test/fakes/test_browser_state.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| 11 namespace { | 11 namespace { |
| 12 class TestSupportsUserData : public base::SupportsUserData { | 12 class TestSupportsUserData : public base::SupportsUserData { |
| 13 public: | 13 public: |
| 14 TestSupportsUserData() {} | 14 TestSupportsUserData() {} |
| 15 ~TestSupportsUserData() override {} | 15 ~TestSupportsUserData() override {} |
| 16 }; | 16 }; |
| 17 } // namespace | 17 } // namespace |
| 18 | 18 |
| 19 TEST(BrowserStateTest, FromSupportsUserData_NullPointer) { | 19 TEST(BrowserStateTest, FromSupportsUserData_NullPointer) { |
| 20 DCHECK_EQ(static_cast<web::BrowserState*>(nullptr), | 20 DCHECK_EQ(static_cast<web::BrowserState*>(nullptr), |
| 21 web::BrowserState::FromSupportsUserData(nullptr)); | 21 web::BrowserState::FromSupportsUserData(nullptr)); |
| 22 } | 22 } |
| 23 | 23 |
| 24 TEST(BrowserStateTest, FromSupportsUserData_NonBrowserState) { | 24 TEST(BrowserStateTest, FromSupportsUserData_NonBrowserState) { |
| 25 TestSupportsUserData supports_user_data; | 25 TestSupportsUserData supports_user_data; |
| 26 DCHECK_EQ(static_cast<web::BrowserState*>(nullptr), | 26 DCHECK_EQ(static_cast<web::BrowserState*>(nullptr), |
| 27 web::BrowserState::FromSupportsUserData(&supports_user_data)); | 27 web::BrowserState::FromSupportsUserData(&supports_user_data)); |
| 28 } | 28 } |
| 29 | 29 |
| 30 TEST(BrowserStateTest, FromSupportsUserData) { | 30 TEST(BrowserStateTest, FromSupportsUserData) { |
| 31 web::TestBrowserState browser_state; | 31 web::TestBrowserState browser_state; |
| 32 DCHECK_EQ(&browser_state, | 32 DCHECK_EQ(&browser_state, |
| 33 web::BrowserState::FromSupportsUserData(&browser_state)); | 33 web::BrowserState::FromSupportsUserData(&browser_state)); |
| 34 } | 34 } |
| OLD | NEW |