browser_state_unittest.mm 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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
  3. // found in the LICENSE file.
  4. #include "ios/web/public/browser_state.h"
  5. #import <WebKit/WebKit.h>
  6. #include "base/supports_user_data.h"
  7. #import "base/test/ios/wait_util.h"
  8. #include "ios/web/public/test/fakes/fake_browser_state.h"
  9. #import "ios/web/web_state/ui/wk_web_view_configuration_provider.h"
  10. #include "testing/gtest/include/gtest/gtest.h"
  11. #include "testing/platform_test.h"
  12. #if !defined(__has_feature) || !__has_feature(objc_arc)
  13. #error "This file requires ARC support."
  14. #endif
  15. using base::test::ios::WaitUntilConditionOrTimeout;
  16. using base::test::ios::kWaitForPageLoadTimeout;
  17. namespace {
  18. class TestSupportsUserData : public base::SupportsUserData {
  19. public:
  20. TestSupportsUserData() {}
  21. ~TestSupportsUserData() override {}
  22. };
  23. } // namespace
  24. using BrowserStateTest = PlatformTest;
  25. TEST_F(BrowserStateTest, FromSupportsUserData_NullPointer) {
  26. DCHECK_EQ(static_cast<web::BrowserState*>(nullptr),
  27. web::BrowserState::FromSupportsUserData(nullptr));
  28. }
  29. TEST_F(BrowserStateTest, FromSupportsUserData_NonBrowserState) {
  30. TestSupportsUserData supports_user_data;
  31. DCHECK_EQ(static_cast<web::BrowserState*>(nullptr),
  32. web::BrowserState::FromSupportsUserData(&supports_user_data));
  33. }
  34. TEST_F(BrowserStateTest, FromSupportsUserData) {
  35. web::FakeBrowserState browser_state;
  36. DCHECK_EQ(&browser_state,
  37. web::BrowserState::FromSupportsUserData(&browser_state));
  38. }