1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 #include "gtest/gtest.h" 6 #include "nsCOMPtr.h" 7 #include "nsIRunnable.h" 8 #include "mozilla/Services.h" 9 #include "nsIObserverService.h" 10 11 extern "C" nsIObserverService* Rust_ObserveFromRust(); 12 TEST(RustXpcom,ObserverFromRust)13TEST(RustXpcom, ObserverFromRust) { 14 nsCOMPtr<nsIObserverService> rust = Rust_ObserveFromRust(); 15 nsCOMPtr<nsIObserverService> cpp = mozilla::services::GetObserverService(); 16 EXPECT_EQ(rust, cpp); 17 } 18 19 extern "C" void Rust_ImplementRunnableInRust(bool* aItWorked, 20 nsIRunnable** aRunnable); 21 TEST(RustXpcom,ImplementRunnableInRust)22TEST(RustXpcom, ImplementRunnableInRust) { 23 bool itWorked = false; 24 nsCOMPtr<nsIRunnable> runnable; 25 Rust_ImplementRunnableInRust(&itWorked, getter_AddRefs(runnable)); 26 27 EXPECT_TRUE(runnable); 28 EXPECT_FALSE(itWorked); 29 runnable->Run(); 30 EXPECT_TRUE(itWorked); 31 } 32