TestQMResult.cpp (1868B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #include "Common.h" 8 #include "gtest/gtest.h" 9 #include "mozilla/dom/QMResult.h" 10 11 using namespace mozilla; 12 using namespace mozilla::dom::quota; 13 14 class DOM_Quota_QMResult : public DOM_Quota_Test {}; 15 16 #ifdef QM_ERROR_STACKS_ENABLED 17 TEST_F(DOM_Quota_QMResult, Construct_Default) { 18 QMResult res; 19 20 IncreaseExpectedStackId(); 21 22 ASSERT_EQ(res.StackId(), ExpectedStackId()); 23 ASSERT_EQ(res.FrameId(), 1u); 24 ASSERT_EQ(res.NSResult(), NS_OK); 25 } 26 #endif 27 28 TEST_F(DOM_Quota_QMResult, Construct_FromNSResult) { 29 QMResult res(NS_ERROR_FAILURE); 30 31 #ifdef QM_ERROR_STACKS_ENABLED 32 IncreaseExpectedStackId(); 33 34 ASSERT_EQ(res.StackId(), ExpectedStackId()); 35 ASSERT_EQ(res.FrameId(), 1u); 36 ASSERT_EQ(res.NSResult(), NS_ERROR_FAILURE); 37 #else 38 ASSERT_EQ(res, NS_ERROR_FAILURE); 39 #endif 40 } 41 42 #ifdef QM_ERROR_STACKS_ENABLED 43 TEST_F(DOM_Quota_QMResult, Propagate) { 44 QMResult res1(NS_ERROR_FAILURE); 45 46 IncreaseExpectedStackId(); 47 48 ASSERT_EQ(res1.StackId(), ExpectedStackId()); 49 ASSERT_EQ(res1.FrameId(), 1u); 50 ASSERT_EQ(res1.NSResult(), NS_ERROR_FAILURE); 51 52 QMResult res2 = res1.Propagate(); 53 54 ASSERT_EQ(res2.StackId(), ExpectedStackId()); 55 ASSERT_EQ(res2.FrameId(), 2u); 56 ASSERT_EQ(res2.NSResult(), NS_ERROR_FAILURE); 57 } 58 #endif 59 60 TEST_F(DOM_Quota_QMResult, ToQMResult) { 61 auto res = ToQMResult(NS_ERROR_FAILURE); 62 63 #ifdef QM_ERROR_STACKS_ENABLED 64 IncreaseExpectedStackId(); 65 66 ASSERT_EQ(res.StackId(), ExpectedStackId()); 67 ASSERT_EQ(res.FrameId(), 1u); 68 ASSERT_EQ(res.NSResult(), NS_ERROR_FAILURE); 69 #else 70 ASSERT_EQ(res, NS_ERROR_FAILURE); 71 #endif 72 }